http-client-private.h revision e47c2f17d8136c4d972d1074a3f84ba2ecef4fdc
#ifndef HTTP_CLIENT_PRIVATE_H
#define HTTP_CLIENT_PRIVATE_H
#include "connection.h"
#include "http-url.h"
#include "http-client.h"
#define HTTP_DEFAULT_PORT 80
#define HTTPS_DEFAULT_PORT 443
struct http_client_host;
struct http_client_host_port;
struct http_client_peer;
struct http_client_connection;
HASH_TABLE_DEFINE_TYPE(http_client_host, const char *,
struct http_client_host *);
struct http_client_peer *);
enum http_client_peer_addr_type {
};
struct http_client_peer_addr {
const char *https_name; /* TLS SNI */
};
struct http_client_request {
unsigned int refcount;
const char *label;
struct http_url origin_url;
const char *authority;
struct http_client *client;
struct http_client_host *host;
struct http_client_peer *peer;
struct http_client_connection *conn;
struct istream *payload_input;
struct ostream *payload_output;
unsigned int attempts;
unsigned int redirects;
unsigned int delayed_error_status;
const char *delayed_error;
struct timeout *to_delayed_error;
void *context;
void (*destroy_callback)(void *);
void *destroy_context;
enum http_request_state state;
unsigned int have_hdr_connection:1;
unsigned int have_hdr_date:1;
unsigned int have_hdr_expect:1;
unsigned int have_hdr_host:1;
unsigned int have_hdr_body_spec:1;
unsigned int have_hdr_user_agent:1;
unsigned int payload_sync:1;
unsigned int payload_chunked:1;
unsigned int payload_wait:1;
unsigned int urgent:1;
unsigned int submitted:1;
unsigned int connect_tunnel:1;
unsigned int connect_direct:1;
unsigned int ssl_tunnel:1;
};
struct http_client_host_port {
struct http_client_host *host;
struct http_client_peer_addr addr;
char *https_name;
/* current index in host->ips */
unsigned int ips_connect_idx;
/* the first IP that started the current round of connection attempts.
initially 0, and later set to the ip index of the last successful
connected IP */
unsigned int ips_connect_start_idx;
/* peers we are trying to connect to;
this can be more than one when soft connect timeouts are enabled */
/* requests pending in queue to be picked up by connections */
struct timeout *to_connect;
};
struct http_client_host {
struct http_client *client;
char *name;
/* the ip addresses DNS returned for this host */
unsigned int ips_count;
/* list of requests in this host that are waiting for ioloop */
/* requests are managed on a per-port basis */
/* active DNS lookup */
struct dns_lookup *dns_lookup;
};
struct http_client_peer {
struct http_client_peer_addr addr;
char *https_name;
struct http_client *client;
/* hosts served through this peer */
/* active connections to this peer */
/* zero time-out for consolidating request handling */
struct timeout *to_req_handling;
unsigned int last_connect_failed:1;
connections */
};
struct http_client_connection {
struct connection conn;
struct http_client_peer *peer;
struct http_client *client;
unsigned int refcount;
const char *label;
unsigned int id; // DEBUG: identify parallel connections
int connect_errno;
struct timeval connect_start_timestamp;
struct timeval connected_timestamp;
struct http_client_request *connect_request;
struct ssl_iostream *ssl_iostream;
struct http_response_parser *http_parser;
struct timeout *to_requests;
struct http_client_request *pending_request;
struct istream *incoming_payload;
struct io *io_req_payload;
/* requests that have been sent, waiting for response */
connection into tunnel */
unsigned int connect_succeeded:1;
unsigned int closing:1;
unsigned int close_indicated:1;
request */
};
struct http_client {
struct http_client_settings set;
struct ssl_iostream_context *ssl_ctx;
struct connection_list *conn_list;
struct http_client_host *hosts_list;
struct http_client_peer *peers_list;
unsigned int pending_requests;
};
static inline const char *
{
}
static inline const char *
{
return t_strdup_printf("[%s %s%s]",
}
}
static inline void
struct http_client_peer_addr *addr)
{
if (req->connect_direct) {
if (req->ssl_tunnel)
else
} else {
}
}
static inline const char *
{
return t_strdup_printf("%s%s [%d]",
}
static inline const char *
{
return t_strconcat
}
}
const char **error_r);
const char **error_r);
struct http_response *response);
const struct http_client_tunnel *tunnel,
struct http_response *response);
struct http_response *response);
struct connection_list *http_client_connection_list_init(void);
struct http_client_connection *
unsigned int
struct http_client_tunnel *tunnel);
unsigned int http_client_peer_addr_hash
(const struct http_client_peer_addr *peer1,
struct http_client_peer *
const struct http_client_peer_addr *addr);
struct http_client_host *host);
struct http_client_host *host);
struct http_client_host *host);
struct http_client_request *
bool no_urgent);
const char *reason);
struct http_client_host *
struct http_client_request *req);
struct http_client_request *
struct http_client_request *
const struct http_client_peer_addr *addr);
const struct http_client_peer_addr *addr);
unsigned int
const struct http_client_peer_addr *addr);
struct http_client_request *req);
#endif