5.6.0.0R1
Software Development Kit
ltrx_http.h File Reference

Definitions related to HTTP server. More...

Data Structures

struct  ltrx_http_dynamic_callback
 HTTP server dynamic callback. More...
 
struct  ltrx_http_query_data
 HTTP server query data. More...
 

Enumerations

enum  ltrx_http_header_content_type { LTRX_HTTP_HEADER_CONTENT_TYPE__TEXT_PLAIN, LTRX_HTTP_HEADER_CONTENT_TYPE__MULTIPART_FORM_DATA, LTRX_HTTP_HEADER_CONTENT_TYPE__APPLICATION_X_WWW_FORM_URLENCODED, LTRX_HTTP_HEADER_CONTENT_TYPE__OTHERS }
 HTTP server header content types. More...
 
enum  ltrx_http_header_method {
  LTRX_HTTP_HEADER_METHOD__GET, LTRX_HTTP_HEADER_METHOD__POST, LTRX_HTTP_HEADER_METHOD__PUT, LTRX_HTTP_HEADER_METHOD__DELETE,
  LTRX_HTTP_HEADER_METHOD__MKCOL, LTRX_HTTP_HEADER_METHOD__OPTIONS, LTRX_HTTP_HEADER_METHOD__OTHERS
}
 HTTP server header methods. More...
 

Functions

void ltrx_ajax_end_response (struct ltrx_http_client *client)
 ltrx_ajax_end_response construct the ending of an ajax response. More...
 
void ltrx_ajax_register (const struct ltrx_http_ajax *ajaxDef)
 ltrx_ajax_register registers a callback function for a specific URL. More...
 
void ltrx_ajax_send_xml_end (struct ltrx_http_client *client)
 ltrx_ajax_send_xml_end sends the end of a xml level in an ajax response. More...
 
void ltrx_ajax_send_xml_node_end (struct ltrx_http_client *client, const char *target)
 ltrx_ajax_send_xml_node_end sends the end of a raw xml node in an ajax response. More...
 
void ltrx_ajax_send_xml_node_start (struct ltrx_http_client *client, const char *target)
 ltrx_ajax_send_xml_node_start sends the start of a raw xml node in an ajax response. More...
 
void ltrx_ajax_send_xml_node_unsigned (struct ltrx_http_client *client, const char *target, uint32_t value)
 ltrx_ajax_send_xml_node_unsigned sends the a xml node with an unsigned integer value. More...
 
void ltrx_ajax_send_xml_start (struct ltrx_http_client *client, const char *target, const char *attribute)
 ltrx_ajax_send_xml_start sends the start of a xml level in an ajax response. More...
 
void ltrx_ajax_start_response (struct ltrx_http_client *client)
 ltrx_ajax_start_response construct the start of an ajax response. More...
 
void ltrx_http_dynamic_callback_register (const struct ltrx_http_dynamic_callback *hdc)
 Register a dynamic callback. More...
 
void ltrx_http_error (struct ltrx_http_client *pClient)
 Declares an error on the HTTP client. More...
 
enum ltrx_http_header_content_type ltrx_http_get_content_type (struct ltrx_http_client *client)
 Get content type. More...
 
enum ltrx_http_header_method ltrx_http_get_header_method (const struct ltrx_http_client *client)
 Get header method. More...
 
const char * ltrx_http_get_request_path (const struct ltrx_http_client *client)
 Retrieves the HTTP request path for the current HTTP client. More...
 
const char * ltrx_http_get_request_query_data (const struct ltrx_http_client *client)
 Retrieves the complete HTTP GET request query string. More...
 
bool ltrx_http_multipart_process (struct ltrx_http_client *client, struct ltrx_http_query_data *query_data[], bool(*unknownKeyHandler)(struct ltrx_http_client *client, struct ltrx_http_multipart_parse_data *pMultipart_Data, const char *key, const char *attribute_key, void *arg), void *arg, struct ltrx_write_user_message_info *lwumi)
 Process key/value parameters in HTTP POST request multipart/form-data body. More...
 
int ltrx_http_multipart_read_char (struct ltrx_http_client *client, struct ltrx_http_multipart_parse_data *pData)
 Reads a single character from a multipart stream. More...
 
int ltrx_http_read_char_from_body_stream (struct ltrx_http_client *client)
 Reads a single character from the body stream. More...
 
void ltrx_http_send_data_encoded (struct ltrx_http_client *client, const char *data)
 Encodes and sends data to the HTTP client. More...
 
void ltrx_http_send_data_flush (struct ltrx_http_client *client)
 Pushes out any pending data to the HTTP client. More...
 

Detailed Description

Definitions related to HTTP server.

Function Documentation

◆ ltrx_ajax_end_response()

void ltrx_ajax_end_response ( struct ltrx_http_client *  client)

ltrx_ajax_end_response construct the ending of an ajax response.

Parameters
clientCurrent HTTP client context.
Usage/Comments:
This call constructs the ending of an ajax response in xml format. Before an ajax callback returns, it must call this function once all data is written.

◆ ltrx_ajax_register()

void ltrx_ajax_register ( const struct ltrx_http_ajax *  ajaxDef)

ltrx_ajax_register registers a callback function for a specific URL.

Parameters
ajaxDefStatic struct containing registerName and callback
Usage/Comments:
Callback is only invoked in the following situations: 1) If registerName starts with '/', an HTTP GET request for http://&lt;hostname&gt;/ajax/&lt;registerName&gt; will invoke callback. 2) Otherwise, an HTTP POST request for http://&lt;hostname&gt;/ with the first post parameter ajax=<registerName> will invoke callback.

Note: The support of HTTP POST is the same ajax framework like in Nuevo products. The support of HTTP GET is a short cut to allow more generic support for HTTP GET request. Forming a HTTP GET request technically does not require any of our ajax framework (ajax.js). Therefore, callback invoked can stream any data format as long as user's javascript callback knows how to process it. (We probably need some more touchup to complete the generic support like raw httpWrite, forming httpHeader, etc.). We may want to create separate api to register generic get/post request and cleanup this shortcut in the future. In our internal webpages, we have tied it to PollData (ajax.js) to allow pure data being returned without invoking any javascript function (processResponse in ajax.js). Although we still forms the response with <ajax> (ltrx_ajax_start_response), our js callback really does not care about it and it is only interested in the data in the response.

◆ ltrx_ajax_send_xml_end()

void ltrx_ajax_send_xml_end ( struct ltrx_http_client *  client)

ltrx_ajax_send_xml_end sends the end of a xml level in an ajax response.

Parameters
clientCurrent HTTP client context.
Usage/Comments:
This is called after all argument data is sent for ltrx_ajax_send_xml_start.

◆ ltrx_ajax_send_xml_node_end()

void ltrx_ajax_send_xml_node_end ( struct ltrx_http_client *  client,
const char *  target 
)

ltrx_ajax_send_xml_node_end sends the end of a raw xml node in an ajax response.

Parameters
clientCurrent HTTP client context.
targetName of xml node.
Usage/Comments:
This is called after all data is sent for ltrx_ajax_send_xml_node_start.

◆ ltrx_ajax_send_xml_node_start()

void ltrx_ajax_send_xml_node_start ( struct ltrx_http_client *  client,
const char *  target 
)

ltrx_ajax_send_xml_node_start sends the start of a raw xml node in an ajax response.

Parameters
clientCurrent HTTP client context.
targetName of xml node.
Usage/Comments:
ltrx_ajax_send_xml_node_end must be called after all data is sent. Note: This is typically used in conjuction with ltrx_ajax_send_xml_start to send the argument data. This function can also be used to construct raw xml format output for a generic HTTP GET response.

◆ ltrx_ajax_send_xml_node_unsigned()

void ltrx_ajax_send_xml_node_unsigned ( struct ltrx_http_client *  client,
const char *  target,
uint32_t  value 
)

ltrx_ajax_send_xml_node_unsigned sends the a xml node with an unsigned integer value.

Parameters
clientCurrent HTTP client context.
targetName of xml node.
valueUnsigned integer value.
Usage/Comments:

◆ ltrx_ajax_send_xml_start()

void ltrx_ajax_send_xml_start ( struct ltrx_http_client *  client,
const char *  target,
const char *  attribute 
)

ltrx_ajax_send_xml_start sends the start of a xml level in an ajax response.

Parameters
clientCurrent HTTP client context.
targetName of javascript function to be invoked.
attributeName of javascript function argument.
Usage/Comments:
This is typically used in an ajax callback to handle POST request. When ajax framework (ajax.js) receives the response, it will try to call (eval) the javascript function named target with the optional argument in xml format. ltrx_ajax_send_xml_end must be called after all argument data is sent. This is useful to drive web development from C code.

◆ ltrx_ajax_start_response()

void ltrx_ajax_start_response ( struct ltrx_http_client *  client)

ltrx_ajax_start_response construct the start of an ajax response.

Parameters
clientCurrent HTTP client context.
Usage/Comments:
This call constructs the HTTP Header and starts streaming out an ajax response in xml format. An ajax callback should call this function before streaming out any data through current http client and it must call ltrx_ajax_end_response once all data is written.