libxr — developer's documentation

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

Macros | Typedefs | Enumerations | Functions
xr-http.h File Reference

HTTP Transport. More...

`#include <glib.h>`
`#include <openssl/bio.h>`

Go to the source code of this file.

## Macros

#define | XR_HTTP_ERROR xr_http_error_quark()

## Typedefs

typedef struct _xr_http | xr_http
| Opaque HTTP object. More...

## 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. More...
xr_http * | xr_http_new (BIO *bio)
| Create new HTTP transport object. More...
void | xr_http_free (xr_http *http)
| Destroy HTTP transport object. More...
gboolean | xr_http_read_header (xr_http *http, GError **err)
| Read HTTP message header. More...
const char * | xr_http_get_header (xr_http *http, const char *name)
| Get specific HTTP header from incomming messages by its name. More...
void | xr_http_set_basic_auth (xr_http *http, const char *username, const char *password)
| Set Authorization: Basic header. More...
gboolean | xr_http_get_basic_auth (xr_http *http, char **username, char **password)
| Decode Authorization header. More...
const char * | xr_http_get_method (xr_http *http)
| Get HTTP method. More...
int | xr_http_get_code (xr_http *http)
| Get HTTP response code. More...
const char * | xr_http_get_resource (xr_http *http)
| Get resource (only if xr_http_get_message_type() == XR_HTTP_REQUEST). More...
int | xr_http_get_version (xr_http *http)
| Get HTTP request version. More...
xr_http_message_type | xr_http_get_message_type (xr_http *http)
| Get message type. More...
gssize | xr_http_get_message_length (xr_http *http)
| Get length of the message body (Content-Length header value). More...
gssize | xr_http_read (xr_http *http, char *buffer, gsize length, GError **err)
| Read HTTP message body. More...
GString * | xr_http_read_all (xr_http *http, GError **err)
| Read whole message body into a GString object. More...
void | xr_http_set_header (xr_http *http, const char *name, const char *value)
| Set HTTP header for outgoing message. More...
void | xr_http_set_message_type (xr_http *http, xr_http_message_type type)
| Set outgoing message type. More...
void | xr_http_set_message_length (xr_http *http, gsize length)
| Set Content-Length header for outgoing message. More...
void | xr_http_setup_request (xr_http *http, const char *method, const char *resource, const char *host)
| Setup outgoing request. More...
void | xr_http_setup_response (xr_http *http, int code)
| Setup outgoing response. More...
gboolean | xr_http_write_header (xr_http *http, GError **err)
| Write outgoing message header. More...
gboolean | xr_http_write (xr_http *http, const char *buffer, gsize length, GError **err)
| Write response body. More...
gboolean | xr_http_write_complete (xr_http *http, GError **err)
| Complete message. More...
gboolean | xr_http_write_all (xr_http *http, const char *buffer, gssize length, GError **err)
| Write whole message body at once from the GString. More...
gboolean | xr_http_is_ready (xr_http *http)
| Check if object is ready to receive or send message. More...
gboolean | xr_http_has_pending_request (xr_http *http, time_t timeout)
| Check if object has pending request to be read within given time. More...
GQuark | xr_http_error_quark ()

## Detailed Description

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.

Documentation for libxr, Fri Apr 15 2016 08:12:18.