35#ifndef A11_NET_HTTP_FETCH_H_
36#define A11_NET_HTTP_FETCH_H_
43#include <absl/status/status.h>
44#include <absl/time/time.h>
58 std::function<void(std::uint64_t bytes_done, std::uint64_t bytes_total)>;
66using FetchSink = std::function<absl::Status(std::string_view chunk)>;
80 absl::Duration
timeout = absl::Minutes(5);
122 FetchOptions options = {},
137 std::string url, FetchOptions options,
const FetchSink& sink,
Shared handle to one asynchronous result.
Definition future.h:126
Completion values used by every asynchronous A11 operation.
A11's nghttp2 HTTP/2 client, server, and streaming primitives.
absl::StatusOr< HttpResponseHead > FetchBlocking(std::string url, FetchOptions options, const FetchSink &sink, const OnFetchProgress &on_progress)
The blocking core of FetchToSink, for a caller already on a fiber.
Definition fetch.cc:238
a11::Future< HttpResponseHead > FetchToSink(std::string url, FetchSink sink, FetchOptions options, OnFetchProgress on_progress)
Fetches url and hands the body to sink as it arrives.
Definition fetch.cc:277
std::vector< std::pair< std::string, std::string > > HttpHeaders
An ordered list of (name, value) HTTP/2 header fields.
Definition http2.h:70
std::function< void(std::uint64_t bytes_done, std::uint64_t bytes_total)> OnFetchProgress
Called as a body arrives.
Definition fetch.h:58
std::function< absl::Status(std::string_view chunk)> FetchSink
Receives body chunks in order.
Definition fetch.h:66
a11::Future< HttpResponse > Fetch(std::string url, FetchOptions options)
Fetches url and buffers the whole response.
Definition fetch.cc:252
What to request, and how hard to try.
Definition fetch.h:69
absl::Duration timeout
Wall-clock bound on the whole operation, redirects included.
Definition fetch.h:80
std::string method
Request method.
Definition fetch.h:70
absl::Status Validate() const
Definition fetch.cc:222
int max_redirects
Redirects to follow before giving up.
Definition fetch.h:78
Http2Options transport
Transport settings.
Definition fetch.h:87
HttpHeaders headers
Extra request headers.
Definition fetch.h:71
std::string body
Request body, for methods that take one.
Definition fetch.h:72
bool default_user_agent
Send a default user-agent when headers does not carry one.
Definition fetch.h:89
Body-size limits, buffering thresholds, deadline, TLS, and HTTP protocol negotiation for an HTTP clie...
Definition http2.h:150