Home --> Documentations --> PJLIB-UTIL Reference

http_client.h
Go to the documentation of this file.
1 /* $Id: http_client.h 3841 2011-10-24 09:28:13Z ming $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 #ifndef __PJLIB_UTIL_HTTP_CLIENT_H__
20 #define __PJLIB_UTIL_HTTP_CLIENT_H__
21 
26 #include <pj/activesock.h>
27 #include <pjlib-util/types.h>
28 
30 
43 typedef struct pj_http_req pj_http_req;
44 
49 #define PJ_HTTP_HEADER_SIZE 32
50 
54 typedef struct pj_http_header_elmt
55 {
59 
65 typedef struct pj_http_headers
66 {
68  unsigned count;
69 
73 
77 typedef struct pj_http_auth_cred
78 {
87 
96 
103 
110  unsigned data_type;
111 
119 
121 
122 
127 typedef struct pj_http_req_param
128 {
134 
140 
146 
152 
157  void *user_data;
158 
164 
179  {
180  void *data;
184  } reqdata;
185 
190 
203 
211 
220 
222 
226 typedef struct pj_http_auth_chal
227 {
233  int stale;
237 
241 typedef struct pj_http_resp
242 {
251  void *data;
253 } pj_http_resp;
254 
258 typedef struct pj_http_url
259 {
266 } pj_http_url;
267 
271 typedef struct pj_http_req_callback
272 {
280  void (*on_response)(pj_http_req *http_req, const pj_http_resp *resp);
281 
298  void (*on_send_data)(pj_http_req *http_req,
299  void **data, pj_size_t *size);
300 
314  void (*on_data_read)(pj_http_req *http_req,
315  void *data, pj_size_t size);
316 
340  void (*on_complete)(pj_http_req *http_req,
341  pj_status_t status,
342  const pj_http_resp *resp);
343 
345 
346 
352 PJ_DECL(void) pj_http_req_param_default(pj_http_req_param *param);
353 
366  pj_str_t *name,
367  pj_str_t *val);
368 
382  char *name, char *val);
383 
393 PJ_DECL(pj_status_t) pj_http_req_parse_url(const pj_str_t *url,
394  pj_http_url *hurl);
395 
414  const pj_str_t *url,
415  pj_timer_heap_t *timer,
416  pj_ioqueue_t *ioqueue,
417  const pj_http_req_param *param,
418  const pj_http_req_callback *hcb,
419  pj_http_req **http_req);
420 
429 PJ_DECL(void) pj_http_req_set_timeout(pj_http_req *http_req,
430  const pj_time_val* timeout);
431 
441 PJ_DECL(pj_status_t) pj_http_req_start(pj_http_req *http_req);
442 
455 PJ_DECL(pj_status_t) pj_http_req_cancel(pj_http_req *http_req,
456  pj_bool_t notify);
457 
465 PJ_DECL(pj_status_t) pj_http_req_destroy(pj_http_req *http_req);
466 
475 PJ_DECL(pj_bool_t) pj_http_req_is_running(const pj_http_req *http_req);
476 
485 PJ_DECL(void *) pj_http_req_get_user_data(pj_http_req *http_req);
486 
491 PJ_END_DECL
492 
493 
494 #endif /* __PJLIB_UTIL_HTTP_CLIENT_H__ */
pj_str_t algorithm
Definition: http_client.h:234
int stale
Definition: http_client.h:233
struct pj_timer_heap_t pj_timer_heap_t
pj_str_t host
Definition: http_client.h:263
Definition: http_client.h:258
int addr_family
Definition: http_client.h:133
pj_str_t reason
Definition: http_client.h:245
PJ_BEGIN_DECL typedef int pj_int32_t
pj_str_t domain
Definition: http_client.h:230
pj_str_t value
Definition: http_client.h:57
int pj_bool_t
Definition: http_client.h:271
pj_size_t total_size
Definition: http_client.h:182
pj_str_t scheme
Definition: http_client.h:86
void * pj_http_req_get_user_data(pj_http_req *http_req)
Definition: http_client.h:178
pj_status_t pj_http_req_cancel(pj_http_req *http_req, pj_bool_t notify)
pj_status_t pj_http_req_create(pj_pool_t *pool, const pj_str_t *url, pj_timer_heap_t *timer, pj_ioqueue_t *ioqueue, const pj_http_req_param *param, const pj_http_req_callback *hcb, pj_http_req **http_req)
pj_str_t path
Definition: http_client.h:265
Definition: http_client.h:226
void(* on_response)(pj_http_req *http_req, const pj_http_resp *resp)
Definition: http_client.h:280
unsigned count
Definition: http_client.h:68
pj_str_t qop
Definition: http_client.h:235
pj_str_t opaque
Definition: http_client.h:232
int pj_status_t
pj_str_t username
Definition: http_client.h:102
pj_str_t data
Definition: http_client.h:118
void(* on_data_read)(pj_http_req *http_req, void *data, pj_size_t size)
Definition: http_client.h:314
pj_str_t realm
Definition: http_client.h:229
Definition: http_client.h:127
struct pj_ioqueue_t pj_ioqueue_t
Definition: http_client.h:54
pj_str_t name
Definition: http_client.h:56
pj_status_t pj_http_req_parse_url(const pj_str_t *url, pj_http_url *hurl)
void * user_data
Definition: http_client.h:157
pj_uint16_t port
Definition: http_client.h:264
pj_str_t version
Definition: http_client.h:145
pj_str_t method
Definition: http_client.h:139
pj_status_t pj_http_req_start(pj_http_req *http_req)
pj_str_t realm
Definition: http_client.h:95
#define PJ_BEGIN_DECL
struct pj_http_req pj_http_req
Definition: http_client.h:43
pj_uint16_t max_retries
Definition: http_client.h:219
pj_status_t pj_http_headers_add_elmt(pj_http_headers *headers, pj_str_t *name, pj_str_t *val)
pj_int32_t content_length
Definition: http_client.h:249
void * data
Definition: http_client.h:180
Definition: http_client.h:65
void(* on_complete)(pj_http_req *http_req, pj_status_t status, const pj_http_resp *resp)
Definition: http_client.h:340
void * data
Definition: http_client.h:251
pj_http_headers headers
Definition: http_client.h:163
pj_str_t scheme
Definition: http_client.h:228
pj_time_val timeout
Definition: http_client.h:151
pj_uint16_t source_port_range_start
Definition: http_client.h:202
void pj_http_req_param_default(pj_http_req_param *param)
pj_http_auth_cred auth_cred
Definition: http_client.h:189
pj_str_t passwd
Definition: http_client.h:261
unsigned data_type
Definition: http_client.h:110
pj_bool_t pj_http_req_is_running(const pj_http_req *http_req)
pj_http_headers headers
Definition: http_client.h:246
pj_uint16_t source_port_range_size
Definition: http_client.h:210
pj_str_t username
Definition: http_client.h:260
void pj_http_req_set_timeout(pj_http_req *http_req, const pj_time_val *timeout)
pj_str_t nonce
Definition: http_client.h:231
pj_status_t pj_http_req_destroy(pj_http_req *http_req)
Definition: http_client.h:77
pj_size_t size
Definition: http_client.h:252
pj_str_t protocol
Definition: http_client.h:262
pj_http_header_elmt header[32]
Definition: http_client.h:71
Definition: http_client.h:241
pj_str_t version
Definition: http_client.h:243
unsigned short pj_uint16_t
#define PJ_HTTP_HEADER_SIZE
Definition: http_client.h:49
size_t pj_size_t
pj_uint16_t status_code
Definition: http_client.h:244
void(* on_send_data)(pj_http_req *http_req, void **data, pj_size_t *size)
Definition: http_client.h:298
pj_status_t pj_http_headers_add_elmt2(pj_http_headers *headers, char *name, char *val)
pj_size_t size
Definition: http_client.h:181
pj_http_auth_chal auth_chal
Definition: http_client.h:247

 


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.