http-client.h revision 4c4c4a740bbb1b674d4b0dae009d1919f8ad96b7
#ifndef HTTP_CLIENT_H
#define HTTP_CLIENT_H
#include "net.h"
#include "http-response.h"
struct timeval;
struct http_response;
struct http_client;
struct http_client_request;
enum http_client_request_error {
};
enum http_request_state {
};
extern const char *http_request_state_names[];
struct http_client_settings {
/* a) If dns_client is set, all lookups are done via it.
b) If dns_client_socket_path is set, each DNS lookup does its own
dns-lookup UNIX socket connection.
c) Otherwise, blocking gethostbyname() lookups are used. */
struct dns_client *dns_client;
const char *dns_client_socket_path;
const char *ssl_crypto_device;
bool ssl_allow_invalid_cert;
/* user cert */
/* User-Agent: header (default: none) */
const char *user_agent;
/* configuration for using a proxy */
const char *proxy_socket_path; /* FIXME: implement */
const char *proxy_username;
const char *proxy_password;
const char *rawlog_dir;
unsigned int max_idle_time_msecs;
/* maximum number of parallel connections per peer (default = 1) */
unsigned int max_parallel_connections;
/* maximum number of pipelined requests per connection (default = 1) */
unsigned int max_pipelined_requests;
/* don't automatically act upon redirect responses */
bool no_auto_redirect;
/* if we use a proxy, delegate SSL negotiation to proxy, rather than
creating a CONNECT tunnel through the proxy for the SSL link */
bool no_ssl_tunnel;
/* maximum number of redirects for a request
(default = 0; redirects refused)
*/
unsigned int max_redirects;
/* maximum number of attempts for a request */
unsigned int max_attempts;
/* maximum number of connection attempts to a host before all associated
requests fail.
if > 1, the maximum will be enforced across all IPs for that host,
meaning that IPs may be tried more than once eventually if the number
of IPs is smaller than the specified maximum attempts. If the number of IPs
is higher than the maximum attempts, not all IPs are tried. If <= 1, all
IPs are tried at most once.
*/
unsigned int max_connect_attempts;
/* Initial backoff time; doubled at each connection failure */
unsigned int connect_backoff_time_msecs;
/* Maximum backoff time */
unsigned int connect_backoff_max_time_msecs;
/* response header limits */
/* max total time to wait for HTTP request to finish
this can be overridden/reset for individual requests using
http_client_request_set_timeout() and friends.
(default is no timeout)
*/
unsigned int request_absolute_timeout_msecs;
/* max time to wait for HTTP request to finish before retrying
(default = unlimited) */
unsigned int request_timeout_msecs;
/* max time to wait for connect() (and SSL handshake) to finish before
retrying (default = request_timeout_msecs) */
unsigned int connect_timeout_msecs;
/* time to wait for connect() (and SSL handshake) to finish for the first
connection before trying the next IP in parallel
(default = 0; wait until current connection attempt finishes) */
unsigned int soft_connect_timeout_msecs;
/* maximum acceptable delay in seconds for automatically
retrying/redirecting requests. if a server sends a response with a
Retry-After header that causes a delay longer than this, the request
is not automatically retried and the response is returned */
unsigned int max_auto_retry_delay;
bool debug;
};
struct http_client_tunnel {
};
typedef void
void *context);
/* create new HTTP request */
struct http_client_request *
CALLBACK_TYPECHECK(callback, void (*)( \
struct http_client_request *
CALLBACK_TYPECHECK(callback, void (*)( \
/* create new HTTP CONNECT request. If this HTTP is configured to use a proxy,
a CONNECT request will be submitted at that proxy, otherwise the connection
is created directly. Call http_client_request_start_tunnel() to
to take over the connection.
*/
struct http_client_request *
void *context);
CALLBACK_TYPECHECK(callback, void (*)( \
struct http_client_request *
void *context);
CALLBACK_TYPECHECK(callback, void (*)( \
bool ssl);
const char *key);
unsigned int msecs);
unsigned int msecs);
enum http_request_state
/* Call the specified callback when HTTP request is destroyed. */
void (*callback)(void *),
void *context);
/* submits request and blocks until provided payload is sent. Multiple calls
are allowed; payload transmission is ended with
http_client_request_finish_payload(). */
struct http_client_tunnel *tunnel);
/* blocks until all currently submitted requests are handled */
/* Returns number of pending HTTP requests. */
#endif