Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Distribution::HttpClient Class Referenceexport

GET a URL, streaming the body to a sink, over whichever transport it is given. More...

Public Member Functions

 HttpClient (std::shared_ptr< const IHttpTransport > transport)
HttpResult get (const HttpRequest &request, const SinkCallback &sink, const ProgressCallback &progress={}) const
HttpResult getString (const HttpRequest &request, std::string &body) const
 GET a small resource into a string.
std::string transportName () const
 The transport underneath, for messages. "none" when this build has no client.

Detailed Description

GET a URL, streaming the body to a sink, over whichever transport it is given.

Redirects are followed here rather than by the transport, for one reason: the authorization header must be dropped when the host changes. HuggingFace redirects LFS files to a pre-signed CDN URL that carries its own authorization and needs no token, and forwarding one there hands it to whoever operates that host. Following hops above the transport is what lets that rule be written once instead of once per implementation.

A resume request answered 200 rather than 206 is reported as RangeIgnored rather than treated as success: the server is sending the whole file, so appending it to an existing partial would silently concatenate.

Member Function Documentation

◆ getString()

HttpResult Mila::Distribution::HttpClient::getString ( const HttpRequest & request,
std::string & body ) const
inline

GET a small resource into a string.

For manifests and API responses. Not for artifacts – it buffers the whole body.


The documentation for this class was generated from the following file: