|
Home --> Documentations --> PJLIB-UTIL Reference
http_client.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __PJLIB_UTIL_HTTP_CLIENT_H__
00020 #define __PJLIB_UTIL_HTTP_CLIENT_H__
00021
00026 #include <pj/activesock.h>
00027 #include <pjlib-util/types.h>
00028
00029 PJ_BEGIN_DECL
00030
00043 typedef struct pj_http_req pj_http_req;
00044
00049 #define PJ_HTTP_HEADER_SIZE 32
00050
00054 typedef struct pj_http_header_elmt
00055 {
00056 pj_str_t name;
00057 pj_str_t value;
00058 } pj_http_header_elmt;
00059
00065 typedef struct pj_http_headers
00066 {
00068 unsigned count;
00069
00071 pj_http_header_elmt header[PJ_HTTP_HEADER_SIZE];
00072 } pj_http_headers;
00073
00077 typedef struct pj_http_auth_cred
00078 {
00086 pj_str_t scheme;
00087
00095 pj_str_t realm;
00096
00102 pj_str_t username;
00103
00110 unsigned data_type;
00111
00118 pj_str_t data;
00119
00120 } pj_http_auth_cred;
00121
00122
00127 typedef struct pj_http_req_param
00128 {
00133 int addr_family;
00134
00139 pj_str_t method;
00140
00145 pj_str_t version;
00146
00151 pj_time_val timeout;
00152
00157 void *user_data;
00158
00163 pj_http_headers headers;
00164
00178 struct pj_http_reqdata
00179 {
00180 void *data;
00181 pj_size_t size;
00182 pj_size_t total_size;
00184 } reqdata;
00185
00189 pj_http_auth_cred auth_cred;
00190
00202 pj_uint16_t source_port_range_start;
00203
00210 pj_uint16_t source_port_range_size;
00211
00219 pj_uint16_t max_retries;
00220
00221 } pj_http_req_param;
00222
00226 typedef struct pj_http_auth_chal
00227 {
00228 pj_str_t scheme;
00229 pj_str_t realm;
00230 pj_str_t domain;
00231 pj_str_t nonce;
00232 pj_str_t opaque;
00233 int stale;
00234 pj_str_t algorithm;
00235 pj_str_t qop;
00236 } pj_http_auth_chal;
00237
00241 typedef struct pj_http_resp
00242 {
00243 pj_str_t version;
00244 pj_uint16_t status_code;
00245 pj_str_t reason;
00246 pj_http_headers headers;
00247 pj_http_auth_chal auth_chal;
00249 pj_int32_t content_length;
00251 void *data;
00252 pj_size_t size;
00253 } pj_http_resp;
00254
00258 typedef struct pj_http_url
00259 {
00260 pj_str_t username;
00261 pj_str_t passwd;
00262 pj_str_t protocol;
00263 pj_str_t host;
00264 pj_uint16_t port;
00265 pj_str_t path;
00266 } pj_http_url;
00267
00271 typedef struct pj_http_req_callback
00272 {
00280 void (*on_response)(pj_http_req *http_req, const pj_http_resp *resp);
00281
00298 void (*on_send_data)(pj_http_req *http_req,
00299 void **data, pj_size_t *size);
00300
00314 void (*on_data_read)(pj_http_req *http_req,
00315 void *data, pj_size_t size);
00316
00340 void (*on_complete)(pj_http_req *http_req,
00341 pj_status_t status,
00342 const pj_http_resp *resp);
00343
00344 } pj_http_req_callback;
00345
00346
00352 PJ_DECL(void) pj_http_req_param_default(pj_http_req_param *param);
00353
00365 PJ_DECL(pj_status_t) pj_http_headers_add_elmt(pj_http_headers *headers,
00366 pj_str_t *name,
00367 pj_str_t *val);
00368
00381 PJ_DECL(pj_status_t) pj_http_headers_add_elmt2(pj_http_headers *headers,
00382 char *name, char *val);
00383
00393 PJ_DECL(pj_status_t) pj_http_req_parse_url(const pj_str_t *url,
00394 pj_http_url *hurl);
00395
00413 PJ_DECL(pj_status_t) pj_http_req_create(pj_pool_t *pool,
00414 const pj_str_t *url,
00415 pj_timer_heap_t *timer,
00416 pj_ioqueue_t *ioqueue,
00417 const pj_http_req_param *param,
00418 const pj_http_req_callback *hcb,
00419 pj_http_req **http_req);
00420
00429 PJ_DECL(void) pj_http_req_set_timeout(pj_http_req *http_req,
00430 const pj_time_val* timeout);
00431
00441 PJ_DECL(pj_status_t) pj_http_req_start(pj_http_req *http_req);
00442
00455 PJ_DECL(pj_status_t) pj_http_req_cancel(pj_http_req *http_req,
00456 pj_bool_t notify);
00457
00465 PJ_DECL(pj_status_t) pj_http_req_destroy(pj_http_req *http_req);
00466
00475 PJ_DECL(pj_bool_t) pj_http_req_is_running(const pj_http_req *http_req);
00476
00485 PJ_DECL(void *) pj_http_req_get_user_data(pj_http_req *http_req);
00486
00491 PJ_END_DECL
00492
00493
00494 #endif
PJLIB-UTIL Open Source, small footprint, and portable asynchronous/caching DNS resolver, text scanner, STUN client, and XML library
Copyright (C) 2006-2009 Teluu Inc.
|