NodeC  0.1
HTTP Input and Output.

HTTP incoming and outgoing data. More...

Macros

#define using_http_out(stream, out)
 
#define NODEC_CHUNKED
 Use this as a content_length to use a chunked transfer encoding in http_out_send_status_body() and http_resp_send_status_body(). More...
 

Typedefs

typedef struct _http_in_t http_in_t
 HTTP incoming data object.
 
typedef struct _http_out_t http_out_t
 HTTP outgoing data object.
 

Functions

void http_in_clear (http_in_t *in)
 
void http_in_clearv (lh_value inv)
 
size_t async_http_in_init (http_in_t *in, uv_stream_t *stream, bool is_request)
 
const char * http_in_url (http_in_t *in)
 
http_method_t http_in_method (http_in_t *in)
 
http_status_t http_in_status (http_in_t *in)
 
const char * http_in_status_info (http_in_t *in)
 
uint64_t http_in_content_length (http_in_t *in)
 
const char * http_in_header (http_in_t *in, const char *name)
 
const char * http_in_header_next (http_in_t *in, const char **value, size_t *iter)
 
bool http_in_header_contains (http_in_t *req, const char *name, const char *pattern)
 
const char * http_header_next_field (const char *header, size_t *len, const char **iter)
 
size_t async_http_in_read_headers (http_in_t *in)
 
nodec_bstream_thttp_in_body (http_in_t *in)
 Get a buffered stream to read the body. More...
 
uv_buf_t async_http_in_read_body (http_in_t *in, size_t read_max)
 Read the full body; the returned buf should be deallocated by the caller. More...
 
void http_in_status_print (http_in_t *in)
 Print a response for debugging purposes;.
 
void http_out_init (http_out_t *out, nodec_stream_t *stream)
 
void http_out_init_server (http_out_t *out, nodec_stream_t *stream, const char *server_name)
 
void http_out_init_client (http_out_t *out, nodec_stream_t *stream, const char *host_name)
 
void http_out_clear (http_out_t *out)
 
void http_out_clearv (lh_value respv)
 
void http_out_add_header (http_out_t *out, const char *field, const char *value)
 
void http_out_send_status (http_out_t *out, http_status_t status)
 
nodec_stream_thttp_out_send_status_body (http_out_t *out, http_status_t status, size_t content_length, const char *content_type)
 
void http_out_send_request (http_out_t *out, http_method_t method, const char *url)
 
nodec_stream_thttp_out_send_request_body (http_out_t *out, http_method_t method, const char *url, size_t content_length, const char *content_type)
 
bool http_out_status_sent (http_out_t *out)
 

Detailed Description

HTTP incoming and outgoing data.

These are the request- and response objects for the server, and the response- and request objects for a client connection. Servers bind these implicitly to http_req() and http_resp() for the current request- and response objects so that the explicit http_in_t and http_out_t objects don't need to be threaded around explicitly.

Macro Definition Documentation

◆ NODEC_CHUNKED

#define NODEC_CHUNKED

Use this as a content_length to use a chunked transfer encoding in http_out_send_status_body() and http_resp_send_status_body().

Function Documentation

◆ async_http_in_read_body()

uv_buf_t async_http_in_read_body ( http_in_t in,
size_t  read_max 
)

Read the full body; the returned buf should be deallocated by the caller.

Uses Content-Length when possible to read into a pre-allocated buffer of the right size.

◆ http_in_body()

nodec_bstream_t* http_in_body ( http_in_t in)

Get a buffered stream to read the body.

Parameters
inthe HTTP input.
Returns
NULL if the stream has no body or was already completely read. Use async_read_bufx() to read most efficiently without memory copies.