David Fletcher / Mbed 2 deprecated CC3000WebServer

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

HTTP Response modules

HTTP Response modules

This module implements routines to allow content handler modules to build and send HTTP responses back to the client. More...

Modules

 Supported HTTP status codes

Functions

void HttpResponse_Headers (uint16 uConnection, uint16 uHttpStatus, uint16 uFlags, uint32 uContentLength, struct HttpBlob contentType, struct HttpBlob location)
 Respond with the specified HTTP status and headers.
void HttpResponse_GetPacketSendBuffer (struct HttpBlob *pPacketSendBuffer)
 Retrieves the pointer and size of the packet-send buffer This function should be called by content handlers that wish to use the already-allocated packet-send buffer in calls to HttpResponse_Content()
void HttpResponse_Content (uint16 uConnection, struct HttpBlob content)
 Send response content to the client.
void HttpResponse_CannedRedirect (uint16 uConnection, struct HttpBlob location, uint16 bPermanent)
 Sends a canned response, with an HTTP redirect This function should be called *instead* of HttpResponse_Status(), HttpResponse_Headers() and HttpResponse_Content()
void HttpResponse_CannedError (uint16 uConnection, uint16 uHttpStatus)
 Sends a canned response, with an error message This function should be called *instead* of HttpResponse_Status(), HttpResponse_Headers() and HttpResponse_Content()

Detailed Description

This module implements routines to allow content handler modules to build and send HTTP responses back to the client.

There are two layers in this module:

  • The lower layer consists of HttpResponse_Headers() and HttpResponse_Content(). These routines allow the caller to specify all details of the response.
  • The higher layer consists of HttpResponse_Canned*(). These routines emit canned (pre-made) responses, such as redirects and errors, which are useful in many situations.

Function Documentation

void HttpResponse_CannedError ( uint16  uConnection,
uint16  uHttpStatus 
)

Sends a canned response, with an error message This function should be called *instead* of HttpResponse_Status(), HttpResponse_Headers() and HttpResponse_Content()

Parameters:
uConnectionThe connection number, as it appears in the HttpRequest structure
uHttpStatusThe HTTP error status. Must be one of HTTP_STATUS_ERROR_*

Definition at line 1247 of file HttpCore.cpp.

void HttpResponse_CannedRedirect ( uint16  uConnection,
struct HttpBlob  location,
uint16  bPermanent 
)

Sends a canned response, with an HTTP redirect This function should be called *instead* of HttpResponse_Status(), HttpResponse_Headers() and HttpResponse_Content()

Parameters:
uConnectionThe connection number, as it appears in the HttpRequest structure
pLocationThe redirect URL
bPermanentzero for temporary redirect, nonzero for permanent redirect

Definition at line 1239 of file HttpCore.cpp.

void HttpResponse_Content ( uint16  uConnection,
struct HttpBlob  content 
)

Send response content to the client.

This function may be called more than once, until all the content is sent.

Parameters:
uConnectionThe connection number, as it appears in the HttpRequest structure
contentContent blob to send to the client.

Definition at line 1223 of file HttpCore.cpp.

void HttpResponse_GetPacketSendBuffer ( struct HttpBlob pPacketSendBuffer )

Retrieves the pointer and size of the packet-send buffer This function should be called by content handlers that wish to use the already-allocated packet-send buffer in calls to HttpResponse_Content()

Parameters:
[out]pPacketSendBufferReturns the pointer and size of the packet-send buffer

Definition at line 1217 of file HttpCore.cpp.

void HttpResponse_Headers ( uint16  uConnection,
uint16  uHttpStatus,
uint16  uFlags,
uint32  uContentLength,
struct HttpBlob  contentType,
struct HttpBlob  location 
)

Respond with the specified HTTP status and headers.

Parameters:
uConnectionThe connection number, as it appears in the HttpRequest structure
uHttpStatusThe HTTP status number to response with. Must be one of HTTP_STATUS_*
uFlagsFlags which are manifested in the response headers. See HTTP_RESPONSE_FLAG_*
uContentLengthThe total length of content which will be sent via HttpResponse_Content()
contentTypeThe content type string, or NULL to omit the content type
locationA string which will be used for the Location header, or NULL to omit the Location header

Definition at line 1128 of file HttpCore.cpp.