http-client-private.h revision e1f9521e847757342e10b3c8d330e7a47f4ce286
#ifndef HTTP_CLIENT_PRIVATE_H
#define HTTP_CLIENT_PRIVATE_H
#include "connection.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 *);
struct http_client_request {
unsigned int refcount;
unsigned int port;
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 payload_sync:1;
unsigned int payload_chunked:1;
unsigned int payload_wait:1;
unsigned int ssl:1;
unsigned int urgent:1;
unsigned int submitted:1;
};
struct http_client_host_port {
unsigned int port;
/* current index in host->ips */
unsigned int ips_connect_idx;
/* requests pending in queue to be picked up by connections */
char *https_name;
};
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_addr {
char *https_name; /* TLS SNI */
unsigned int port;
};
struct http_client_peer {
struct http_client_peer_addr addr;
struct http_client *client;
/* hosts served through this peer */
/* active connections to this peer */
unsigned int last_connect_failed:1;
};
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 ssl_iostream *ssl_iostream;
struct http_response_parser *http_parser;
struct http_client_request *pending_request;
struct istream *incoming_payload;
/* requests that have been sent, waiting for response */
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 *
{
return t_strdup_printf("[%s http%s://%s:%d%s]",
}
static inline const char *
{
return t_strdup_printf("%s:%u [%d]",
}
const char **error_r);
const char **error_r);
struct http_response *response);
struct connection_list *http_client_connection_list_init(void);
struct http_client_connection *
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_request *
bool no_urgent);
const char *reason);
struct http_client_host *
struct http_client_request *req);
struct http_client_request *
struct http_client_request *req);
#endif