HTTP Transport. More...
#include <glib.h>#include <openssl/bio.h>Go to the source code of this file.
Defines | |
| #define | XR_HTTP_ERROR xr_http_error_quark() |
Typedefs | |
| typedef struct _xr_http | xr_http |
| Opaque HTTP object. | |
Enumerations | |
| enum | xr_http_message_type { XR_HTTP_NONE, XR_HTTP_REQUEST, XR_HTTP_RESPONSE } |
| Message type (request/response). More... | |
| enum | XRHttpError { XR_HTTP_ERROR_FAILED = 1 } |
Functions | |
| G_BEGIN_DECLS void | xr_http_init () |
| Initialize HTTP transport. | |
| xr_http * | xr_http_new (BIO *bio) |
| Create new HTTP transport object. | |
| void | xr_http_free (xr_http *http) |
| Destroy HTTP transport object. | |
| gboolean | xr_http_read_header (xr_http *http, GError **err) |
| Read HTTP message header. | |
| const char * | xr_http_get_header (xr_http *http, const char *name) |
| Get specific HTTP header from incomming messages by its name. | |
| void | xr_http_set_basic_auth (xr_http *http, const char *username, const char *password) |
| Set Authorization: Basic header. | |
| gboolean | xr_http_get_basic_auth (xr_http *http, char **username, char **password) |
| Decode Authorization header. | |
| const char * | xr_http_get_method (xr_http *http) |
| Get HTTP method. | |
| int | xr_http_get_code (xr_http *http) |
| Get HTTP response code. | |
| const char * | xr_http_get_resource (xr_http *http) |
| Get resource (only if xr_http_get_message_type() == XR_HTTP_REQUEST). | |
| int | xr_http_get_version (xr_http *http) |
| Get HTTP request version. | |
| xr_http_message_type | xr_http_get_message_type (xr_http *http) |
| Get message type. | |
| gssize | xr_http_get_message_length (xr_http *http) |
| Get length of the message body (Content-Length header value). | |
| gssize | xr_http_read (xr_http *http, char *buffer, gsize length, GError **err) |
| Read HTTP message body. | |
| GString * | xr_http_read_all (xr_http *http, GError **err) |
| Read whole message body into a GString object. | |
| void | xr_http_set_header (xr_http *http, const char *name, const char *value) |
| Set HTTP header for outgoing message. | |
| void | xr_http_set_message_type (xr_http *http, xr_http_message_type type) |
| Set outgoing message type. | |
| void | xr_http_set_message_length (xr_http *http, gsize length) |
| Set Content-Length header for outgoing message. | |
| void | xr_http_setup_request (xr_http *http, const char *method, const char *resource, const char *host) |
| Setup outgoing request. | |
| void | xr_http_setup_response (xr_http *http, int code) |
| Setup outgoing response. | |
| gboolean | xr_http_write_header (xr_http *http, GError **err) |
| Write outgoing message header. | |
| gboolean | xr_http_write (xr_http *http, const char *buffer, gsize length, GError **err) |
| Write response body. | |
| gboolean | xr_http_write_complete (xr_http *http, GError **err) |
| Complete message. | |
| gboolean | xr_http_write_all (xr_http *http, const char *buffer, gssize length, GError **err) |
| Write whole message body at once from the GString. | |
| gboolean | xr_http_is_ready (xr_http *http) |
| Check if object is ready to receive or send message. | |
| gboolean | xr_http_has_pending_request (xr_http *http, time_t timeout) |
| Check if object has pending request to be read within given time. | |
| GQuark | xr_http_error_quark () |
HTTP Transport.
xr_http object exists as long as HTTP connection exists. It is used to server multiple requests/responses.
xr_http object is created using xr_http_new(bio) and then user is supposed to call xr_http_read_header() that will receive and parse HTTP header. After that user can call one of xr_http_read() functions to read body of the HTTP request or response.
When request is received, user must generate response using xr_http_write_header() and optionally body using xr_http_write(). Header values can be set using xr_http_setup_request() or xr_http_setup_response() and xr_http_set_header() functions.