Apache HTTPD
Classes | Functions | Variables
md_http.c File Reference
#include <assert.h>
#include <apr_lib.h>
#include <apr_strings.h>
#include <apr_buckets.h>
#include "md_http.h"
#include "md_log.h"
#include "md_util.h"

Go to the source code of this file.

Classes

struct  md_http_t
 
struct  nextreq_proxy_t
 

Functions

void md_http_use_implementation (md_http_impl_t *impl)
 
static apr_status_t http_cleanup (void *data)
 
apr_status_t md_http_create (md_http_t **phttp, apr_pool_t *p, const char *user_agent, const char *proxy_url)
 
apr_status_t md_http_clone (md_http_t **phttp, apr_pool_t *p, md_http_t *source_http)
 
void md_http_set_impl_data (md_http_t *http, void *data)
 
void * md_http_get_impl_data (md_http_t *http)
 
void md_http_set_response_limit (md_http_t *http, apr_off_t resp_limit)
 
void md_http_set_timeout_default (md_http_t *http, apr_time_t timeout)
 
void md_http_set_timeout (md_http_request_t *req, apr_time_t timeout)
 
void md_http_set_connect_timeout_default (md_http_t *http, apr_time_t timeout)
 
void md_http_set_connect_timeout (md_http_request_t *req, apr_time_t timeout)
 
void md_http_set_stalling_default (md_http_t *http, long bytes_per_sec, apr_time_t timeout)
 
void md_http_set_stalling (md_http_request_t *req, long bytes_per_sec, apr_time_t timeout)
 
void md_http_set_ca_file (md_http_t *http, const char *ca_file)
 
void md_http_set_unix_socket_path (md_http_t *http, const char *path)
 
static apr_status_t req_set_body (md_http_request_t *req, const char *content_type, apr_bucket_brigade *body, apr_off_t body_len, int detect_len)
 
static apr_status_t req_set_body_data (md_http_request_t *req, const char *content_type, const md_data_t *body)
 
static apr_status_t req_create (md_http_request_t **preq, md_http_t *http, const char *method, const char *url, struct apr_table_t *headers)
 
void md_http_req_destroy (md_http_request_t *req)
 
void md_http_set_on_status_cb (md_http_request_t *req, md_http_status_cb *cb, void *baton)
 
void md_http_set_on_response_cb (md_http_request_t *req, md_http_response_cb *cb, void *baton)
 
apr_status_t md_http_perform (md_http_request_t *req)
 
static apr_status_t proxy_nextreq (md_http_request_t **preq, void *baton, md_http_t *http, int in_flight)
 
apr_status_t md_http_multi_perform (md_http_t *http, md_http_next_req *nextreq, void *baton)
 
apr_status_t md_http_GET_create (md_http_request_t **preq, md_http_t *http, const char *url, struct apr_table_t *headers)
 
apr_status_t md_http_HEAD_create (md_http_request_t **preq, md_http_t *http, const char *url, struct apr_table_t *headers)
 
apr_status_t md_http_POST_create (md_http_request_t **preq, md_http_t *http, const char *url, struct apr_table_t *headers, const char *content_type, struct apr_bucket_brigade *body, int detect_len)
 
apr_status_t md_http_POSTd_create (md_http_request_t **preq, md_http_t *http, const char *url, struct apr_table_t *headers, const char *content_type, const struct md_data_t *body)
 
apr_status_t md_http_GET_perform (struct md_http_t *http, const char *url, struct apr_table_t *headers, md_http_response_cb *cb, void *baton)
 
apr_status_t md_http_HEAD_perform (struct md_http_t *http, const char *url, struct apr_table_t *headers, md_http_response_cb *cb, void *baton)
 
apr_status_t md_http_POST_perform (struct md_http_t *http, const char *url, struct apr_table_t *headers, const char *content_type, apr_bucket_brigade *body, int detect_len, md_http_response_cb *cb, void *baton)
 
apr_status_t md_http_POSTd_perform (md_http_t *http, const char *url, struct apr_table_t *headers, const char *content_type, const md_data_t *body, md_http_response_cb *cb, void *baton)
 

Variables

static md_http_impl_tcur_impl
 
static int cur_init_done
 

Function Documentation

◆ http_cleanup()

static apr_status_t http_cleanup ( void *  data)
static

Definition at line 52 of file md_http.c.

◆ md_http_clone()

apr_status_t md_http_clone ( md_http_t **  phttp,
apr_pool_t p,
md_http_t source_http 
)

Clone a http instance, inheriting all settings from source_http. The cloned instance is not tied in any way to the source.

Definition at line 95 of file md_http.c.

◆ md_http_create()

apr_status_t md_http_create ( md_http_t **  phttp,
apr_pool_t p,
const char user_agent,
const char proxy_url 
)

Definition at line 61 of file md_http.c.

◆ md_http_GET_create()

apr_status_t md_http_GET_create ( md_http_request_t **  preq,
md_http_t http,
const char url,
struct apr_table_t headers 
)

Create a GET request.

Parameters
preqthe created request after success
httpthe md_http instance
urlthe url to GET
headersrequest headers

Definition at line 291 of file md_http.c.

◆ md_http_get_impl_data()

void * md_http_get_impl_data ( md_http_t http)

Definition at line 119 of file md_http.c.

◆ md_http_GET_perform()

apr_status_t md_http_GET_perform ( struct md_http_t http,
const char url,
struct apr_table_t headers,
md_http_response_cb cb,
void *  baton 
)

Definition at line 349 of file md_http.c.

◆ md_http_HEAD_create()

apr_status_t md_http_HEAD_create ( md_http_request_t **  preq,
md_http_t http,
const char url,
struct apr_table_t headers 
)

Create a HEAD request.

Parameters
preqthe created request after success
httpthe md_http instance
urlthe url to GET
headersrequest headers

Definition at line 302 of file md_http.c.

◆ md_http_HEAD_perform()

apr_status_t md_http_HEAD_perform ( struct md_http_t http,
const char url,
struct apr_table_t headers,
md_http_response_cb cb,
void *  baton 
)

Definition at line 361 of file md_http.c.

◆ md_http_multi_perform()

apr_status_t md_http_multi_perform ( md_http_t http,
md_http_next_req nextreq,
void *  baton 
)

Perform requests in parallel as retrieved from the nextreq function. There are as many requests in flight as the nextreq functions provides.

To limit the number of parallel requests, nextreq should return APR_ENOENT when the limit is reached. It will be called again when the number of in_flight requests changes.

When all requests are done, nextreq will be called one more time. Should it not return anything, this function returns.

Definition at line 282 of file md_http.c.

◆ md_http_perform()

apr_status_t md_http_perform ( md_http_request_t request)

Perform the request. Then this function returns, the request and all its memory has been freed and must no longer be used.

Definition at line 264 of file md_http.c.

◆ md_http_POST_create()

apr_status_t md_http_POST_create ( md_http_request_t **  preq,
md_http_t http,
const char url,
struct apr_table_t headers,
const char content_type,
struct apr_bucket_brigade body,
int  detect_len 
)

Create a POST request with a bucket brigade as request body.

Parameters
preqthe created request after success
httpthe md_http instance
urlthe url to GET
headersrequest headers
content_typethe content_type of the body or NULL
bodythe body of the request or NULL
detect_lenscan the body to detect its length

Definition at line 313 of file md_http.c.

◆ md_http_POST_perform()

apr_status_t md_http_POST_perform ( struct md_http_t http,
const char url,
struct apr_table_t headers,
const char content_type,
apr_bucket_brigade body,
int  detect_len,
md_http_response_cb cb,
void *  baton 
)

Definition at line 373 of file md_http.c.

◆ md_http_POSTd_create()

apr_status_t md_http_POSTd_create ( md_http_request_t **  preq,
md_http_t http,
const char url,
struct apr_table_t headers,
const char content_type,
const struct md_data_t body 
)

Create a POST request with known request body data.

Parameters
preqthe created request after success
httpthe md_http instance
urlthe url to GET
headersrequest headers
content_typethe content_type of the body or NULL
bodythe body of the request or NULL

Definition at line 328 of file md_http.c.

◆ md_http_POSTd_perform()

apr_status_t md_http_POSTd_perform ( md_http_t http,
const char url,
struct apr_table_t headers,
const char content_type,
const md_data_t body,
md_http_response_cb cb,
void *  baton 
)

Definition at line 386 of file md_http.c.

◆ md_http_req_destroy()

void md_http_req_destroy ( md_http_request_t req)

Definition at line 243 of file md_http.c.

◆ md_http_set_ca_file()

void md_http_set_ca_file ( md_http_t http,
const char ca_file 
)

Set a CA file (in PERM format) to use for root certificates when verifying SSL connections. If not set (or set to NULL), the systems certificate store will be used.

Definition at line 161 of file md_http.c.

◆ md_http_set_connect_timeout()

void md_http_set_connect_timeout ( md_http_request_t req,
apr_time_t  timeout 
)

Definition at line 144 of file md_http.c.

◆ md_http_set_connect_timeout_default()

void md_http_set_connect_timeout_default ( md_http_t http,
apr_time_t  timeout 
)

Set the timeout for establishing a connection. Set to 0 the have no special timeout for this.

Definition at line 139 of file md_http.c.

◆ md_http_set_impl_data()

void md_http_set_impl_data ( md_http_t http,
void *  data 
)

get/set data the implementation wants to remember between requests in the same md_http_t instance.

Definition at line 114 of file md_http.c.

◆ md_http_set_on_response_cb()

void md_http_set_on_response_cb ( md_http_request_t req,
md_http_response_cb cb,
void *  baton 
)

Set the callback to be invoked when the complete response has been successfully received. The HTTP status may be 500, however.

Parameters
reqthe request
cbthe callback to invoke on the response
batondata passed to the callback

Definition at line 258 of file md_http.c.

◆ md_http_set_on_status_cb()

void md_http_set_on_status_cb ( md_http_request_t req,
md_http_status_cb cb,
void *  baton 
)

Set the callback to be invoked once the status of a request is known.

Parameters
reqthe request
cbthe callback to invoke on the response
batondata passed to the callback

Definition at line 252 of file md_http.c.

◆ md_http_set_response_limit()

void md_http_set_response_limit ( md_http_t http,
apr_off_t  resp_limit 
)

Definition at line 124 of file md_http.c.

◆ md_http_set_stalling()

void md_http_set_stalling ( md_http_request_t req,
long  bytes_per_sec,
apr_time_t  timeout 
)

Definition at line 155 of file md_http.c.

◆ md_http_set_stalling_default()

void md_http_set_stalling_default ( md_http_t http,
long  bytes_per_sec,
apr_time_t  timeout 
)

Set the condition for when a transfer is considered "stalled", e.g. does not progress at a sufficient rate and will be aborted. Set to 0 the have no stall detection in place.

Definition at line 149 of file md_http.c.

◆ md_http_set_timeout()

void md_http_set_timeout ( md_http_request_t req,
apr_time_t  timeout 
)

Definition at line 134 of file md_http.c.

◆ md_http_set_timeout_default()

void md_http_set_timeout_default ( md_http_t http,
apr_time_t  timeout 
)

Set the timeout for the complete request. This needs to take everything from DNS looksups, to conntects, to transfer of all data into account and should be sufficiently large. Set to 0 the have no timeout for this.

Definition at line 129 of file md_http.c.

◆ md_http_set_unix_socket_path()

void md_http_set_unix_socket_path ( md_http_t http,
const char path 
)

Set the path of a unix domain socket for use instead of TCP in a connection. Disable by providing NULL as path.

Definition at line 166 of file md_http.c.

◆ md_http_use_implementation()

void md_http_use_implementation ( md_http_impl_t impl)

Definition at line 44 of file md_http.c.

◆ proxy_nextreq()

static apr_status_t proxy_nextreq ( md_http_request_t **  preq,
void *  baton,
md_http_t http,
int  in_flight 
)
static

Definition at line 274 of file md_http.c.

◆ req_create()

static apr_status_t req_create ( md_http_request_t **  preq,
md_http_t http,
const char method,
const char url,
struct apr_table_t headers 
)
static

Definition at line 211 of file md_http.c.

◆ req_set_body()

static apr_status_t req_set_body ( md_http_request_t req,
const char content_type,
apr_bucket_brigade body,
apr_off_t  body_len,
int  detect_len 
)
static

Definition at line 171 of file md_http.c.

◆ req_set_body_data()

static apr_status_t req_set_body_data ( md_http_request_t req,
const char content_type,
const md_data_t body 
)
static

Definition at line 195 of file md_http.c.

Variable Documentation

◆ cur_impl

md_http_impl_t* cur_impl
static

Definition at line 41 of file md_http.c.

◆ cur_init_done

int cur_init_done
static

Definition at line 42 of file md_http.c.