00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __nanohttp_client_h
00025 #define __nanohttp_client_h
00026
00027
00028 #ifndef __NHTTP_INTERNAL
00029 #include <nanohttp/nanohttp-error.h>
00030 #include <nanohttp/nanohttp-common.h>
00031 #include <nanohttp/nanohttp-stream.h>
00032 #include <nanohttp/nanohttp-request.h>
00033 #include <nanohttp/nanohttp-response.h>
00034 #endif
00035
00206 typedef struct httpc_conn
00207 {
00208 struct hsocket_t *sock;
00209 hpair_t *header;
00210 struct hurl_t *url;
00211 http_version_t version;
00212
00213 int errcode;
00214 char errmsg[150];
00215 struct http_output_stream_t *out;
00216 int id;
00217 } httpc_conn_t;
00218
00219 #ifdef __cplusplus
00220 extern "C" {
00221 #endif
00222
00236 extern herror_t httpc_init(int argc, char **argv);
00237
00245 extern void httpc_destroy(void);
00246
00257 extern httpc_conn_t *httpc_new(void);
00258
00267 extern void httpc_free(httpc_conn_t * conn);
00268
00277 extern void httpc_close_free(httpc_conn_t * conn);
00278
00291 extern int httpc_set_header(httpc_conn_t * conn, const char *key, const char *value);
00292
00305 extern int httpc_add_header(httpc_conn_t *conn, const char *key, const char *value);
00306
00317 extern void httpc_add_headers(httpc_conn_t *conn, const hpair_t *values);
00318
00331 extern int httpc_set_basic_authorization(httpc_conn_t *conn, const char *user, const char *password);
00332
00345 extern int httpc_set_basic_proxy_authorization(httpc_conn_t *conn, const char *user, const char *password);
00346
00356 extern herror_t httpc_get(httpc_conn_t * conn, hresponse_t ** out, const char *urlstr);
00357
00368 extern herror_t httpc_post_begin(httpc_conn_t * conn, const char *url);
00369
00381 extern herror_t httpc_post_end(httpc_conn_t * conn, hresponse_t ** out);
00382
00398 extern herror_t httpc_mime_begin(httpc_conn_t * conn, const char *url,
00399 const char *related_start,
00400 const char *related_start_info,
00401 const char *related_type);
00402
00412 extern herror_t httpc_mime_next(httpc_conn_t * conn,
00413 const char *content_id,
00414 const char *content_type,
00415 const char *transfer_encoding);
00416
00426 extern herror_t httpc_mime_end(httpc_conn_t * conn, hresponse_t ** out);
00427
00437 extern herror_t httpc_mime_send_file(httpc_conn_t * conn,
00438 const char *content_id,
00439 const char *content_type,
00440 const char *transfer_encoding,
00441 const char *filename);
00442
00443 #ifdef __cplusplus
00444 }
00445 #endif
00446
00449 #endif