NetBurner 3.5.6
PDF Version
HTTP_Request Struct Reference

HTTP Request Structure. More...

#include <http.h>

Public Member Functions

void ProcessLine (PSTR startofline)
 internal function
 
int Respond (int socket)
 internal function
 
bool ExtractAuthentication (char **pPassword, char **pUser)
 used to extract user name and password in authentication test
 
const char * GetBoundaryMarker ()
 Extracts the boundary marker string from multipart Content-Type headers.
 
int ReadSimpleBody (int socket, const char *boundary=NULL)
 Reads the HTTP request body from a socket into the internal buffer and processes termination conditions.
 

Public Attributes

PSTR pURL
 Request URL.
 
PSTR pAuthorization
 Authorization header if present, otherwise null.
 
PSTR pFirstCookie
 First cookie if present, otherwise null. More may follow.
 
PSTR pData
 Pointer to entire data set. Note: not null terminated.
 
PSTR pSep
 Separator for multipart forms, null if not present.
 
PSTR pHost
 Pointer to host record null if not present.
 
PSTR last_datarx
 Pointer to last data read, internal use only.
 
PSTR wsKey
 Web socket ket, internal use only.
 
PSTR wsProtocol
 Web socket prototocl, internal use only.
 
uint16_t sep_len
 Length of separator for multipart forms.
 
uint32_t content_length
 Content length field from HTML header.
 
uint32_t rx_length
 Total bytes receive from request, internal use only.
 
IPADDR client_IPaddr
 IP address of client.
 
uint8_t websocketFlags
 Web socket flags.
 
HTTP_RequestTypes req
 Type of request HTTP_RequestTypes.
 

Detailed Description

HTTP Request Structure.

This structure is populated before a HTTP request is sent out.

Member Function Documentation

◆ GetBoundaryMarker()

const char * HTTP_Request::GetBoundaryMarker ( )

Extracts the boundary marker string from multipart Content-Type headers.

This function searches through the previously parsed HTTP headers to locate and extract the boundary parameter from the Content-Type header when multipart content is present. The boundary marker is used to delimit individual parts within multipart HTTP content such as multipart/form-data or multipart/mixed. The function parses the Content-Type header according to RFC specifications to isolate the boundary value from other Content-Type parameters.

Returns
Pointer to null-terminated string containing the boundary marker value if found, or NULL if no multipart Content-Type header exists or no boundary parameter is specified in the Content-Type header
Note
The returned pointer references internal header data and remains valid as long as the header information is preserved. This function should only be called after HTTP headers have been successfully parsed. The boundary marker does not include the leading "--" prefix used in actual multipart delimiters. Multipart content requires a boundary parameter to be properly processed according to RFC standards.
See also
ReadSimpleBody() for using the boundary marker during body parsing
RFC 2046 for multipart media type specifications

◆ ReadSimpleBody()

int HTTP_Request::ReadSimpleBody ( int socket,
const char * boundary = NULL )

Reads the HTTP request body from a socket into the internal buffer and processes termination conditions.

This function reads the remaining HTTP request body data from an established socket connection into the buffer backing the request object, preparing the pData member for access. The function handles different HTTP body termination scenarios including content-length bounded bodies, chunked transfer encoding, and boundary-delimited content such as multipart data. Reading continues until one of several termination conditions is met, allowing proper handling of various HTTP body formats.

Parameters
socketFile descriptor of the established HTTP connection Must be a valid socket with available data to read
boundaryPointer to null-terminated string containing the boundary sequence that indicates the end of the request body (default: NULL) Used for multipart content or custom termination sequences If NULL, termination is determined by Content-Length or chunked encoding
Returns
HTTP_RRR_END_FOUND if the function successfully found the trailing termination sequence and completed reading the body
HTTP_RRR_FINISHED if all content was read as indicated by HTTP headers (Content-Length reached or chunked encoding completed)
HTTP_RRR_BUFF_FULL if the internal buffer became full before the body was completely read, indicating more data remains available on the socket
HTTP_RRR_SOCK_ERR if a socket error occurred during reading, typically indicating the connection was closed or experienced a network error
Note
This function modifies the internal buffer state and primes the pData member for access. The socket must have HTTP headers already processed before calling this function. For multipart or boundary-terminated content, the boundary parameter must be specified. Buffer overflow conditions require additional reads to retrieve remaining data. The function respects HTTP protocol specifications for body termination.
See also
HTTP_RRR_END_FOUND, HTTP_RRR_FINISHED, HTTP_RRR_BUFF_FULL, HTTP_RRR_SOCK_ERR for return code definitions

The documentation for this struct was generated from the following file: