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 #include <nanohttp/nanohttp-logging.h>
00035 #endif
00036
00199 typedef struct httpc_conn
00200 {
00201 struct hsocket_t *sock;
00202 hpair_t *header;
00203 struct hurl_t *url;
00204 http_version_t version;
00205
00206 int errcode;
00207 char errmsg[150];
00208 struct http_output_stream_t *out;
00209 int id;
00210 } httpc_conn_t;
00211
00212 #ifdef __cplusplus
00213 extern "C" {
00214 #endif
00215
00229 extern herror_t httpc_init(int argc, char **argv);
00230
00238 extern void httpc_destroy(void);
00239
00250 extern httpc_conn_t *httpc_new(void);
00251
00260 extern void httpc_free(httpc_conn_t * conn);
00261
00270 extern void httpc_close_free(httpc_conn_t * conn);
00271
00284 extern int httpc_set_header(httpc_conn_t * conn, const char *key, const char *value);
00285
00298 extern int httpc_add_header(httpc_conn_t *conn, const char *key, const char *value);
00299
00310 extern void httpc_add_headers(httpc_conn_t *conn, const hpair_t *values);
00311
00324 extern int httpc_set_basic_authorization(httpc_conn_t *conn, const char *user, const char *password);
00325
00338 extern int httpc_set_basic_proxy_authorization(httpc_conn_t *conn, const char *user, const char *password);
00339
00349 extern herror_t httpc_get(httpc_conn_t * conn, hresponse_t ** out, const char *urlstr);
00350
00361 extern herror_t httpc_post_begin(httpc_conn_t * conn, const char *url);
00362
00374 extern herror_t httpc_post_end(httpc_conn_t * conn, hresponse_t ** out);
00375
00391 extern herror_t httpc_mime_begin(httpc_conn_t * conn, const char *url,
00392 const char *related_start,
00393 const char *related_start_info,
00394 const char *related_type);
00395
00405 extern herror_t httpc_mime_next(httpc_conn_t * conn,
00406 const char *content_id,
00407 const char *content_type,
00408 const char *transfer_encoding);
00409
00419 extern herror_t httpc_mime_end(httpc_conn_t * conn, hresponse_t ** out);
00420
00430 extern herror_t httpc_mime_send_file(httpc_conn_t * conn,
00431 const char *content_id,
00432 const char *content_type,
00433 const char *transfer_encoding,
00434 const char *filename);
00435
00436 #ifdef __cplusplus
00437 }
00438 #endif
00439
00440 #endif