uproot.source.http.HTTPResource

Defined in uproot.source.http on line 137.

Inheritance order:

  1. uproot.source.chunk.Resource

class uproot.source.http.HTTPResource(file_path, timeout)
Parameters:
  • file_path (str) – A URL of the file to open.

  • timeout (None or float) – An optional timeout in seconds.

A uproot.source.chunk.Resource for HTTP(S) connections.

For simplicity, this resource does not manage a live http.client.HTTPConnection or http.client.HTTPSConnection, though in principle, it could.

timeout

HTTPResource.timeout

The timeout in seconds or None.

parsed_url

HTTPResource.parsed_url

A urllib.parse.ParseResult version of the file_path.

auth_headers

HTTPResource.auth_headers

Returns a dict containing auth headers, if any for this resource

get

HTTPResource.get(connection, start: int, stop: int) bytes
Parameters:
  • start (int) – Seek position of the first byte to include.

  • stop (int) – Seek position of the first byte to exclude (one greater than the last byte to include).

Returns a Python buffer of data between start and stop.

future

static HTTPResource.future(source: Source, start: int, stop: int)
Parameters:
  • source (uproot.HTTPSource or uproot.MultithreadedHTTPSource) – The data source.

  • start (int) – Seek position of the first byte to include.

  • stop (int) – Seek position of the first byte to exclude (one greater than the last byte to include).

Returns a uproot.source.futures.ResourceFuture that calls get with start and stop.

multifuture

static HTTPResource.multifuture(source: uproot.source.chunk.Source, range_header: dict, ranges: list[int, int], futures, results)
Parameters:
  • source (uproot.HTTPSource) – The data source.

  • ranges (list of (int, int) 2-tuples) – Intervals to fetch as (start, stop) pairs in a single request, if possible.

  • futures (dict of (int, int) → uproot.source.futures.ResourceFuture) – Mapping from (start, stop) to a future that is awaiting its result.

  • results (dict of (int, int) → None or numpy.ndarray of numpy.uint8) – Mapping from (start, stop) to None or results.

Returns a uproot.source.futures.ResourceFuture that attempts to perform an HTTP(S) multipart GET, filling results to satisfy the individual uproot.source.chunk.Chunk’s futures with its multipart response.

If the server does not support multipart GET, that same future sets fallback and retries the request without multipart, using a uproot.MultithreadedHTTPSource to fill the same results and futures. Subsequent attempts would immediately use the fallback.

is_multipart_supported

HTTPResource.is_multipart_supported(ranges: list[int, int], response: http.client.HTTPResponse) bool

Helper function for multifuture to check for multipart GET support.

handle_no_multipart

HTTPResource.handle_no_multipart(source: uproot.source.chunk.Source, ranges: list[int, int], futures, results)

Helper function for multifuture to handle a lack of multipart GET support.

handle_multipart

HTTPResource.handle_multipart(source: uproot.source.chunk.Source, futures, results, response: http.client.HTTPResponse, ranges: list[int, int])

Helper function for multifuture to handle the multipart GET response.

next_header

HTTPResource.next_header(response_buffer)

Helper function for multifuture to return the next header from the response_buffer.

partfuture

static HTTPResource.partfuture(results, start: int, stop: int)

Returns a uproot.source.futures.ResourceFuture to simply select the (start, stop) item from the results dict.

In chunks, each chunk has a partfuture that are collectively filled by a single multifuture.

file_path

Inherited from uproot.source.chunk.Resource.

HTTPResource.file_path

A path to the file (or URL).