nanohttp-client.c File Reference

#include "nanohttp-logging.h"
#include "nanohttp-error.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
#include "nanohttp-stream.h"
#include "nanohttp-request.h"
#include "nanohttp-response.h"
#include "nanohttp-base64.h"
#include "nanohttp-url.h"
#include "nanohttp-client.h"

Go to the source code of this file.

Functions

herror_t httpc_init (int argc, char **argv)
void httpc_destroy (void)
httpc_conn_thttpc_new (void)
void httpc_free (httpc_conn_t *conn)
void httpc_close_free (httpc_conn_t *conn)
int httpc_add_header (httpc_conn_t *conn, const char *key, const char *value)
void httpc_add_headers (httpc_conn_t *conn, const hpair_t *values)
int httpc_set_header (httpc_conn_t *conn, const char *key, const char *value)
int httpc_set_basic_authorization (httpc_conn_t *conn, const char *user, const char *password)
int httpc_set_basic_proxy_authorization (httpc_conn_t *conn, const char *user, const char *password)
herror_t httpc_send_header (httpc_conn_t *conn)
herror_t httpc_get (httpc_conn_t *conn, hresponse_t **out, const char *urlstr)
herror_t httpc_post_begin (httpc_conn_t *conn, const char *url)
herror_t httpc_post_end (httpc_conn_t *conn, hresponse_t **out)
herror_t httpc_mime_begin (httpc_conn_t *conn, const char *url, const char *related_start, const char *related_start_info, const char *related_type)
herror_t httpc_mime_next (httpc_conn_t *conn, const char *content_id, const char *content_type, const char *transfer_encoding)
herror_t httpc_mime_end (httpc_conn_t *conn, hresponse_t **out)
herror_t httpc_mime_send_file (httpc_conn_t *conn, const char *content_id, const char *content_type, const char *transfer_encoding, const char *filename)


Function Documentation

int httpc_add_header httpc_conn_t conn,
const char *  key,
const char *  value
 

Adds a header element (key, value) pair.

Returns:
0 on success, -1 on failure.
See also:
httpc_set_header

httpc_add_headers

General Header Fields

Request Header Fields

Definition at line 182 of file nanohttp-client.c.

References httpc_conn::header, hpairnode_new(), and log_warn1.

Referenced by httpc_add_headers().

void httpc_add_headers httpc_conn_t conn,
const hpair_t values
 

Adds a list of (key, value) pairs.

See also:
httpc_set_header

httpc_add_header

General Header Fields

Request Header Fields

Definition at line 196 of file nanohttp-client.c.

References httpc_add_header(), hpair::key, log_warn1, hpair::next, and hpair::value.

void httpc_close_free httpc_conn_t conn  ) 
 

Close and release a connection

See also:
httpc_close

httpc_free

Definition at line 170 of file nanohttp-client.c.

References hsocket_close(), httpc_free(), and httpc_conn::sock.

void httpc_destroy void   ) 
 

Destroys the nanoHTTP client module.

See also:
httpc_init

Definition at line 86 of file nanohttp-client.c.

References hsocket_module_destroy().

Referenced by soap_nhttp_client_destroy().

void httpc_free httpc_conn_t conn  ) 
 

Release a connection (use httpc_close_free() instead)

See also:
httpc_close_free

Definition at line 139 of file nanohttp-client.c.

References httpc_conn::header, hpairnode_free(), hsocket_free(), http_output_stream_free(), hurl_free(), hpair::next, httpc_conn::out, httpc_conn::sock, and httpc_conn::url.

Referenced by httpc_close_free().

herror_t httpc_get httpc_conn_t conn,
hresponse_t **  out,
const char *  urlstr
 

Invoke a "GET" method request and receive the response

Returns:
H_OK on success
See also:
HTTP_REQUEST_GET

Definition at line 445 of file nanohttp-client.c.

References H_OK, herror_message(), hresponse_new_from_socket(), HTTP_REQUEST_GET, log_error2, and httpc_conn::sock.

herror_t httpc_init int  argc,
char **  argv
 

Initializes the nanoHTTP client module.

Parameters:
argc Argument count.
argv Argument vector.
Returns:
H_OK on succes or a herror_t struct on failure.
See also:
httpc_destroy

herror_t

Definition at line 80 of file nanohttp-client.c.

References hsocket_module_init().

Referenced by soap_nhttp_client_init_args().

herror_t httpc_mime_begin httpc_conn_t conn,
const char *  url,
const char *  related_start,
const char *  related_start_info,
const char *  related_type
 

Begin MIME multipart/related POST request

Returns:
H_OK on success or error flag
See also:
nanohttp_mime_page

Definition at line 513 of file nanohttp-client.c.

References HEADER_CONTENT_TYPE, httpc_post_begin(), and httpc_set_header().

herror_t httpc_mime_end httpc_conn_t conn,
hresponse_t **  out
 

Finish MIME request and get the response

Returns:
H_OK on success
See also:
nanohttp_mime_page

Definition at line 581 of file nanohttp-client.c.

References H_OK, hresponse_new_from_socket(), http_output_stream_flush(), http_output_stream_write(), httpc_conn::out, and httpc_conn::sock.

herror_t httpc_mime_next httpc_conn_t conn,
const char *  content_id,
const char *  content_type,
const char *  transfer_encoding
 

Send boundary and part header and continue with next part

Returns:
H_OK on success
See also:
nanohttp_mime_page

Definition at line 556 of file nanohttp-client.c.

References H_OK, HEADER_CONTENT_ID, HEADER_CONTENT_TRANSFER_ENCODING, HEADER_CONTENT_TYPE, http_output_stream_write(), and httpc_conn::out.

Referenced by httpc_mime_send_file().

herror_t httpc_mime_send_file httpc_conn_t conn,
const char *  content_id,
const char *  content_type,
const char *  transfer_encoding,
const char *  filename
 

Send boundary and part header and continue with next part

Definition at line 611 of file nanohttp-client.c.

References FILE_ERROR_OPEN, FILE_ERROR_READ, H_OK, herror_new(), http_output_stream_write(), httpc_mime_next(), log_error2, log_verbose1, MAX_FILE_BUFFER_SIZE, and httpc_conn::out.

httpc_conn_t* httpc_new void   ) 
 

Creates a new HTTP client connection object. You need to create at least one HTTP client connection to communicate via HTTP.

Returns:
A pointer to a httpc_conn_t structure on success, NULL on error.
See also:
httpc_conn_t

Definition at line 94 of file nanohttp-client.c.

References H_OK, httpc_conn::header, herror_message(), hsocket_init(), HTTP_1_1, hurl_free(), httpc_conn::id, log_error2, log_warn2, httpc_conn::out, httpc_conn::sock, httpc_conn::url, and httpc_conn::version.

herror_t httpc_post_begin httpc_conn_t conn,
const char *  url
 

Start a "POST" method request

Returns:
H_OK on success or error flag
See also:
HTTP_REQUEST_POST

httpc_post_end

Definition at line 465 of file nanohttp-client.c.

References H_OK, httpc_conn::header, herror_message(), http_output_stream_new(), HTTP_REQUEST_POST, log_error2, httpc_conn::out, and httpc_conn::sock.

Referenced by httpc_mime_begin().

herror_t httpc_post_end httpc_conn_t conn,
hresponse_t **  out
 

End a "POST" method and receive the response. You MUST call httpc_post_end() before!

Returns:
H_OK on success
See also:
httpc_post_begin

HTTP_REQUEST_POST

Definition at line 486 of file nanohttp-client.c.

References H_OK, hresponse_new_from_socket(), http_output_stream_flush(), httpc_conn::out, and httpc_conn::sock.

herror_t httpc_send_header httpc_conn_t conn  ) 
 

Definition at line 301 of file nanohttp-client.c.

References H_OK, httpc_conn::header, hsocket_send(), hsocket_send_string(), hpair::key, hpair::next, httpc_conn::sock, and hpair::value.

int httpc_set_basic_authorization httpc_conn_t conn,
const char *  user,
const char *  password
 

Sets a HEADER_AUTHORIZATION header.

Parameters:
conn The HTTP connection.
user The username.
password The password.
See also:
httpc_set_header

HEADER_AUTHORIZATION

Definition at line 268 of file nanohttp-client.c.

References HEADER_AUTHORIZATION.

int httpc_set_basic_proxy_authorization httpc_conn_t conn,
const char *  user,
const char *  password
 

Sets a HEADER_PROXY_AUTHORIZATION header.

Parameters:
conn The HTTP connection.
user The username.
password The password.
See also:
httpc_set_header

HEADER_PROXY_AUTHORIZATION

Definition at line 274 of file nanohttp-client.c.

References HEADER_PROXY_AUTHORIZATION.

int httpc_set_header httpc_conn_t conn,
const char *  key,
const char *  value
 

Sets header element (key,value) pair.

Returns:
0 on success or failure (yeah!), 1 if a (key,value) pair was replaced.
See also:
httpc_add_header

httpc_add_headers

General Header Fields

Request Header Fields

Definition at line 217 of file nanohttp-client.c.

References httpc_conn::header, hpairnode_new(), hpair::key, log_warn1, hpair::next, and hpair::value.

Referenced by httpc_mime_begin().


Generated on Thu Jan 25 23:36:03 2007 for csoap by  doxygen 1.4.6