AXHttp
ax_http_handler.h File Reference

The AXHttpHandler handles HTTP requests and responses. More...

Go to the source code of this file.

Typedefs

typedef struct _AXHttpHandler AXHttpHandler
 The AXHttpHandler is an opaque data type used to manage the HTTP API.
 
typedef void(* AXHttpRequestHandler) (const gchar *path, const gchar *method, const gchar *query, GHashTable *params, GOutputStream *output_stream, gpointer user_data)
 This is the prototype of the callback function called whenever a request is made for a registered CGI. The reply must apply to the rules outlined in RFC 3875. If the reply does not comply with RFC 3875 the connection to the client will be terminated and SIGPIPE will be raised. More...
 

Functions

AXHttpHandlerax_http_handler_new (AXHttpRequestHandler request_handler, gpointer user_data)
 Initializes a new AXHttpHandler and registers all CGIs listed in the CGI configuration file. More...
 
void ax_http_handler_free (AXHttpHandler *handler)
 Frees an AXHttpHandler an releases all associated resources. More...
 

Detailed Description

The AXHttpHandler handles HTTP requests and responses.

Typedef Documentation

◆ AXHttpRequestHandler

typedef void(* AXHttpRequestHandler) (const gchar *path, const gchar *method, const gchar *query, GHashTable *params, GOutputStream *output_stream, gpointer user_data)

This is the prototype of the callback function called whenever a request is made for a registered CGI. The reply must apply to the rules outlined in RFC 3875. If the reply does not comply with RFC 3875 the connection to the client will be terminated and SIGPIPE will be raised.

Parameters
pathThe path of the requested CGI.
methodThe method used in the request, either "GET" or "POST"
queryFor a "GET" request, the unmodified query supplied to the CGI. For a "POST" request, the complete message body.
paramsA GHashTable containing the query parsed into keys and values. Only applicable to "GET" requests or "POST" requests with "Content-Type: application/x-www-form-urlencoded".
output_streamAn output stream to post replies on. It's the responsibility of the client to unreference the output stream before returning from the callback.
user_dataThe user data pointer supplied to ax_http_handler_new.

Function Documentation

◆ ax_http_handler_new()

AXHttpHandler* ax_http_handler_new ( AXHttpRequestHandler  request_handler,
gpointer  user_data 
)

Initializes a new AXHttpHandler and registers all CGIs listed in the CGI configuration file.

Parameters
request_handlerThe callback function to call when a request for a CGI is made.
user_dataA pointer that will be supplied with the call to the request_handler.
Returns
A newly created AXHttpHandler if successful, otherwize NULL.
Examples:
ax_http_serve_request.c.

References ax_http_handler_free(), and ax_http_server_socket_new().

◆ ax_http_handler_free()

void ax_http_handler_free ( AXHttpHandler http_handler)

Frees an AXHttpHandler an releases all associated resources.

Parameters
handlerA previously created AXHttpHandler.
Examples:
ax_http_serve_request.c.

References ax_http_server_socket_free().

Referenced by ax_http_handler_new().