XDK API  3.6.0
Documentation
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Serval_Http.h File Reference

Interface to HTTP constantsThis module provides declarations which are commonly used by HTTP. More...

#include <Serval_Defines.h>
#include <Serval_Policy.h>
#include <Serval_Types.h>
#include <Serval_StringDescr.h>
#include <Serval_Msg.h>
+ Include dependency graph for Serval_Http.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  HttpAuthCredential_S
 
struct  HttpRealm_S
 

Macros

#define SERVAL_ENABLE_HTTP_CHUNKED_RECEIVING   1
 
#define SERVAL_ENABLE_HTTP_RANGE_HANDLING   0
 
#define SERVAL_HTTP_AUTH_NONCE_LENGTH   8
 
#define SERVAL_HTTP_MAX_LEN_PASSWORD   10
 
#define SERVAL_HTTP_MAX_LEN_USER_NAME   10
 
#define SERVAL_HTTP_MAX_LENGTH_CNONCE   32
 
#define SERVAL_HTTP_MAX_REALM_NAME   20
 
#define SERVAL_HTTP_SESSION_DENY_KEEP_ALIVE   0
 

Typedefs

typedef char unsigned Hash_T
 
typedef char unsigned HashHex_T
 
typedef struct HttpAuthCredential_S HttpAuthCredential_T
 
typedef struct HttpRealm_S HttpRealm_T
 
typedef struct HttpServerInstance_S HttpServerInstance_T
 
typedef struct HttpSession_S HttpSession_T
 

Enumerations

enum  Http_StatusCode_T
 

Functions

void HttpMsg_getContent (Msg_T *msg_ptr, char const **content_pptr, unsigned int *len_ptr)
 
char const * HttpMsg_getContentType (Msg_T *msg_ptr)
 
char const * HttpMsg_getReqMethod (Msg_T *msg_ptr)
 
char const * HttpMsg_getReqUrl (Msg_T *msg_ptr)
 
Http_StatusCode_T HttpMsg_getStatusCode (Msg_T *msg_ptr)
 
void HttpMsg_serializeCustomHeaders (Msg_T *msg_ptr, OutMsgPartFactoryFunc_T headerSerializationFunction)
 
void HttpMsg_setContentType (Msg_T *msg_ptr, char const *contentType_ptr)
 
retcode_t HttpMsg_setHost (Msg_T *msg_ptr, const char *value)
 
void HttpMsg_setReqMethod (Msg_T *msg_ptr, char const *method)
 
retcode_t HttpMsg_setReqUrl (Msg_T *msg_ptr, char const *url_ptr)
 
void HttpMsg_setStatusCode (Msg_T *msg_ptr, Http_StatusCode_T const respStatus)
 

Variables

const char Http_AuthDigestNcValue []
 
const char Http_AuthDigestOption_cnonce []
 
const char Http_AuthDigestOption_nc []
 
const char Http_AuthDigestOption_nonce []
 
const char Http_AuthDigestOption_qop []
 
const char Http_AuthDigestOption_response []
 
const char Http_AuthDigestOption_stale []
 
const char Http_AuthDigestOption_uri []
 
const char Http_AuthDigestOption_username []
 
const char Http_AuthDigestQop_auth []
 
const char Http_AuthDigestQop_authint []
 
const char Http_Authentication_realm []
 
const char Http_AuthorizationType_Basic []
 
const char Http_AuthorizationType_Digest []
 
const char Http_AuthorizationType_Unknown []
 
const char Http_CacheControl_No []
 
const char Http_CacheControl_Yes []
 
const char Http_Connection_Close []
 
const char Http_Connection_KeepAlive []
 
const char Http_ContentType_App_Exi []
 
const char Http_ContentType_App_Json []
 
const char Http_ContentType_App_OctetStream []
 
const char Http_ContentType_App_Pdf []
 
const char Http_ContentType_App_Soap []
 
const char Http_ContentType_App_Xhtml []
 
const char Http_ContentType_App_Xml []
 
const char Http_ContentType_Image_Bmp []
 
const char Http_ContentType_Image_Gif []
 
const char Http_ContentType_Image_Ico []
 
const char Http_ContentType_Image_Jpeg []
 
const char Http_ContentType_Image_Png []
 
const char Http_ContentType_Text_Css []
 
const char Http_ContentType_Text_Html []
 
const char Http_ContentType_Text_Plain []
 
const char Http_ContentType_Text_Xml []
 
const char Http_ContentType_Unknown []
 
const char Http_Encoding_Chunked []
 
const char Http_Header_AuthenticationInfo []
 
const char Http_Header_Authorization []
 
const char Http_Header_CacheControl []
 
const char Http_Header_Connection []
 
const char Http_Header_ContentLength []
 
const char Http_Header_ContentRange []
 
const char Http_Header_ContentType []
 
const char Http_Header_Expect []
 
const char Http_Header_Server []
 
const char Http_Header_TransferEncoding []
 
const char Http_Method_Delete []
 
const char Http_Method_Get []
 
const char Http_Method_Head []
 
const char Http_Method_Post []
 
const char Http_Method_Put []
 
const char Http_Method_Unknown []
 
const char Http_NewLine []
 
const char Http_Protocol_V10 []
 
const char Http_Protocol_V11 []
 
const char Http_Range_Bytes []
 
const char Http_Space []
 

Macro Definition Documentation

#define SERVAL_ENABLE_HTTP_CHUNKED_RECEIVING   1
#define SERVAL_ENABLE_HTTP_RANGE_HANDLING   0
#define SERVAL_HTTP_AUTH_NONCE_LENGTH   8
#define SERVAL_HTTP_MAX_LEN_PASSWORD   10
#define SERVAL_HTTP_MAX_LEN_USER_NAME   10

if SERVAL_ENABLE_HTTP_AUTH => automatic define user/pwd values

#define SERVAL_HTTP_MAX_LENGTH_CNONCE   32

Maximum length of the client-provided nonce. Setting this value to low will cause digest authorization to fail. However, it is stored in each message, so enlarging it requires additional memory per HTTP message. Firefox 40 uses 16 bytes IE 9 uses 32 bytes

#define SERVAL_HTTP_MAX_REALM_NAME   20
#define SERVAL_HTTP_SESSION_DENY_KEEP_ALIVE   0

The maximal length of a URL. It is also used for Webservice action names and endpoints. This is the maximal number of parallel HTTP sessions. By default, SERVAL_HTTP_MAX_NUM_SESSIONS should be equal to SERVAL_MAX_NUM_MESSAGES, which means that all supported requests may be HTTP requests. However, it is possible to reduce this number if UDP messages are also expected.

Note: Should be equal to actual number of TCP sockets provided on target platform. Define the timeout in ms for garbage collection of HTTP sessions. It should be a multiple of SERVAL_RESOURCE_MONITOR_PERIODE. Suggested is a value 2-5 times as large as SERVAL_RESOURCE_MONITOR_PERIODE. define whether HTTP keepalive session will be denied this should be set to 1 if http session garbage is disabled

Typedef Documentation

typedef char unsigned Hash_T
typedef char unsigned HashHex_T
typedef struct HttpRealm_S HttpRealm_T
typedef struct HttpServerInstance_S HttpServerInstance_T

This data type represents a HTTP service.

See also
struct HttpServerInstance_S
typedef struct HttpSession_S HttpSession_T

This data type represents a HTTP session and holds session related data.

See also
struct HttpSession_S

Enumeration Type Documentation

A selection of HTTP status codes, which are relevant (i.e. generated or interpreted) by the our HTTP implementation.

Enumerator
Http_StatusCode_Invalid 
Http_StatusCode_Continue 
Http_StatusCode_SwitchingProtocols 
Http_StatusCode_OK 
Http_StatusCode_Created 
Http_StatusCode_Accepted 
Http_StatusCode_NonAuthoritativeInformation 
Http_StatusCode_NoContent 
Http_StatusCode_ResetContent 
Http_StatusCode_PartialContent 
Http_StatusCode_MultipleChoices 
Http_StatusCode_MovedPermanently 
Http_StatusCode_Found 
Http_StatusCode_SeeOther 
Http_StatusCode_NotModified 
Http_StatusCode_UseProxy 
Http_StatusCode_TemporaryRedirect 
Http_StatusCode_BadRequest 
Http_StatusCode_Unauthorized 
Http_StatusCode_PaymentRequired 
Http_StatusCode_Forbidden 
Http_StatusCode_NotFound 
Http_StatusCode_MethodNotAllowed 
Http_StatusCode_NotAcceptable 
Http_StatusCode_ProxyAuthenticationRequired 
Http_StatusCode_RequestTimeout 
Http_StatusCode_Conflict 
Http_StatusCode_Gone 
Http_StatusCode_LengthRequired 
Http_StatusCode_PreconditionFailed 
Http_StatusCode_RequestEntityTooLarge 
Http_StatusCode_RequestURITooLarge 
Http_StatusCode_UnsupportedMediaType 
Http_StatusCode_RequestedRangeNotSatisfiable 
Http_StatusCode_ExpectationFailed 
Http_StatusCode_InternalServerError 
Http_StatusCode_NotImplemented 
Http_StatusCode_BadGateway 
Http_StatusCode_ServiceUnavailable 
Http_StatusCode_GatewayTimeout 
Http_StatusCode_HttpVersionNotSupported 

Function Documentation

void HttpMsg_getContent ( Msg_T msg_ptr,
char const **  content_pptr,
unsigned int *  len_ptr 
)

It returns a reference to the beginning of the content of the HTTP message.

Parameters
[in]msg_ptrA reference to the message including the HTTP message. It must be a valid pointer to a valid message.
[out]content_pptrIt will reference to the start of the content. It must be a valid pointer.
[out]len_ptrIt will indicate the length of the content. It must be a valid pointer.
char const* HttpMsg_getContentType ( Msg_T msg_ptr)

This function is called to get the content type of the given message.

Parameters
[in]msg_ptrReference to the Msg_T object to modify. It has to be a valid pointer.
See also
Http_ContentType_Text_Plain, Http_ContentType_Text_Html, Http_ContentType_Image_Gif, Http_ContentType_Image_Png, Http_ContentType_Image_Jpeg, Http_ContentType_Image_Bmp, Http_ContentType_Image_Ico, Http_ContentType_App_Pdf, Http_ContentType_App_Soap
char const* HttpMsg_getReqMethod ( Msg_T msg_ptr)

It returns the HTTP method, e.g. GET, POST, PUT, etc., which is associated with the given HTTP message.

Parameters
[in]msg_ptrA reference to the message including the HTTP message. It must be a valid pointer to a valid message.
Returns
A reference to the string representing the method. It can be also Http_Method_Unknown.
See also
Http_Method_Unknown, Http_Method_Head, Http_Method_Get, Http_Method_Post Http_Method_Put, Http_Method_Delete
char const* HttpMsg_getReqUrl ( Msg_T msg_ptr)

It returns a reference to the URL given in the HTTP message.

Parameters
[in]msg_ptrA reference to the message including the HTTP message. It must be a valid pointer to a valid message.
Returns
A reference to the URL.
Http_StatusCode_T HttpMsg_getStatusCode ( Msg_T msg_ptr)

This function is called to get the status code of the given message.

Parameters
[in]msg_ptrReference to the Msg_T object to read out the status code. It has to be a valid pointer.
See also
Http_StatusCode_T
void HttpMsg_serializeCustomHeaders ( Msg_T msg_ptr,
OutMsgPartFactoryFunc_T  headerSerializationFunction 
)

Add the headers serialized by headerSerializationFunction to the header part of the HTTP message pointed to by msg_ptr.

The function headerSerializationFunction is called after the internal headers have been serialized but before the header-terminating token "\r\n" is added to the message.

The function pointed to by headerSerializationFunction is expected to return either RC_OK if all data has been serialized or RC_MSG_FACTORY_INCOMPLETE if insufficient space was available to serialize all data. Any other return code is interpreted as an error which aborts sending the message.

After RC_OK is returned, the stack will insert the header-terminating token "\r\n" and proceed with serialization of the content of the message, if present.

In the call to headerSerializationFunction, both position and offset of the OutMsgSerializationHandover_T are available for tracking incremental progress of serialization. Useful helper functions are also TcpMsg_copyStaticContent and TcpMsg_copyContentAtomic. As an example how this can be used, see the code below:

static retcode_t serializeMyHeaders(OutMsgSerializationHandover_T *omsh_ptr)
{
omsh_ptr->len = 0;
int n;
static const char* myheader1 = "MyHeader: Value\r\n";
static const char* myheader2 = "MyOtherHeader: OtherValue\r\n";
switch(omsh_ptr->position)
{
case 0:
n = strlen(myheader1);
rc = TcpMsg_copyStaticContent(omsh_ptr, myheader1, n);
if ( rc != RC_OK ) return rc;
omsh_ptr->position = 1;
// no-break
case 1:
n = strlen(myheader2);
rc = TcpMsg_copyContentAtomic(omsh_ptr, myheader2, n);
if ( rc != RC_OK ) return rc;
omsh_ptr->position = 2;
// no-break
default:
return RC_OK;
}
}
Parameters
[in]msg_ptrThe message for which custom headers are to be serialized. MUST NOT be NULL
[in]headerSerializationFunctionThe function to serialize the custom headers. May be NULL to unset the function
See also
TcpMsg_copyStaticContent, TcpMsg_copyContentAtomic
void HttpMsg_setContentType ( Msg_T msg_ptr,
char const *  contentType_ptr 
)

This function is called to set the content type to be used in the response for the given message.

Parameters
[in]msg_ptrReference to the Msg_T object to modify. It has to be a valid pointer.
[in]contentType_ptrThe content type to set.
See also
Http_ContentType_Text_Plain, Http_ContentType_Text_Html, Http_ContentType_Image_Gif, Http_ContentType_Image_Png, Http_ContentType_Image_Jpeg, Http_ContentType_Image_Bmp, Http_ContentType_Image_Ico, Http_ContentType_App_Pdf, Http_ContentType_App_Soap
retcode_t HttpMsg_setHost ( Msg_T msg_ptr,
const char *  value 
)

Sets the Host header of the Http message.

The Host header can be used to send a request to a virtual HTTP site, i.e. a site that is accessible via multiple DNS entries.

If a call to this function is omitted or NULL is passed as the value, or the length of the Host header would be larger than SERVAL_MAX_SIZE_APP_PACKET, the stack will use the IP and port of the target as the Host value.

The value is not copied, therefore the hostname must remain valid, 0-terminated memory until the message has been sent.

Also note that this header is only serialized in requests. Setting it on response messages will not produce an error but is equally pointless.

Parameters
[in]msg_ptrThe message for which the Host header is to be set. MUST NOT be NULL.
[in]valueThe value of the header to be set
Returns
RC_OK on success
RC_HTTP_TOO_LONG_URL if the Host header could not fit into a packet
void HttpMsg_setReqMethod ( Msg_T msg_ptr,
char const *  method 
)

This function is called to set the HTTP Request Method (GET, POST, PUT, etc).

Parameters
[in]msg_ptrA reference to the message including the HTTP message. It must be a valid pointer to a valid message.
[in]methodA reference to the string representing the method to be set.
See also
Http_Method_Unknown, Http_Method_Head, Http_Method_Get, Http_Method_Post Http_Method_Put, Http_Method_Delete
retcode_t HttpMsg_setReqUrl ( Msg_T msg_ptr,
char const *  url_ptr 
)

This function is called to set the URL in the HTTP Request given by the message.

Parameters
[in]msg_ptrA reference to the message including the HTTP message. It must be a valid pointer to a valid message.
[in]url_ptrPointer to URL to be stored in given HTTP Request message.
Returns
RC_OK on success
RC_HTTP_TOO_LONG_URL if url is too long
void HttpMsg_setStatusCode ( Msg_T msg_ptr,
Http_StatusCode_T const  respStatus 
)

This function is called to set the HTTP status code to be used in the response for the given message.

Parameters
[in]msg_ptrReference to the Msg_T object to modify. It has to be a valid pointer.
[in]respStatusThe HTTP status code to set in the web message.

Variable Documentation

const char Http_AuthDigestNcValue[]

Standard String value of HTTP Header Option field value nonce count

const char Http_AuthDigestOption_cnonce[]

String value of HTTP Header Option cnonce

const char Http_AuthDigestOption_nc[]

String value of HTTP Header Option nonce count

const char Http_AuthDigestOption_nonce[]

String value of HTTP Header Option nonce

const char Http_AuthDigestOption_qop[]

String value of HTTP Header Option qop

const char Http_AuthDigestOption_response[]

String value of HTTP Header Option response

const char Http_AuthDigestOption_stale[]

String value of HTTP Header option stale

const char Http_AuthDigestOption_uri[]

String value of HTTP Header Option digesturi

const char Http_AuthDigestOption_username[]

String value of HTTP Header Option username

const char Http_AuthDigestQop_auth[]

String value of HTTP Header Option qop-option

const char Http_AuthDigestQop_authint[]

String value of HTTP Header Option qop-option

const char Http_Authentication_realm[]

String value of HTTP Header option realm

const char Http_AuthorizationType_Basic[]

String value of Authorization for indicating Basic Authorization

const char Http_AuthorizationType_Digest[]

String value of Authorization for indicating Digest Authorization

const char Http_AuthorizationType_Unknown[]

String value of Authorization for indicating Unknown Authorization

const char Http_CacheControl_No[]

String value of Cache-Control for indicating no cache-control

const char Http_CacheControl_Yes[]

String value of Cache-Control for indicating cache-control

const char Http_Connection_Close[]

String value of Connection for indicating non-persistent connection

const char Http_Connection_KeepAlive[]

String value of Connection for indicating keep-alive

const char Http_ContentType_App_Exi[]

String value of Content Type for indicating EXI data

const char Http_ContentType_App_Json[]

String value of Content Type for indicating XML data

const char Http_ContentType_App_OctetStream[]

String value of Content Type for indicating arbitrary binary data

const char Http_ContentType_App_Pdf[]

String value of Content Type for indicating Portable Document Format

const char Http_ContentType_App_Soap[]

String value of Content Type for indicating SOAP

const char Http_ContentType_App_Xhtml[]

String value of Content Type for indicating XHTML data

const char Http_ContentType_App_Xml[]

String value of Content Type for indicating XML data

const char Http_ContentType_Image_Bmp[]

String value of Content Type for indicating Microsoft Windows bitmap

const char Http_ContentType_Image_Gif[]

String value of Content Type for indicating GIF image

const char Http_ContentType_Image_Ico[]

String value of Content Type for indicating icon

const char Http_ContentType_Image_Jpeg[]

String value of Content Type for indicating JPEG JFIF image

const char Http_ContentType_Image_Png[]

String value of Content Type for indicating Portable Network Graphics

const char Http_ContentType_Text_Css[]

String value of Content Type for indicating CSS data

const char Http_ContentType_Text_Html[]

String value of Content Type for indicating HTML data

const char Http_ContentType_Text_Plain[]

String value of Content Type for indicating Textual data

const char Http_ContentType_Text_Xml[]

String value of Content Type for indicating XML data

const char Http_ContentType_Unknown[]

String value of an unknown Content Type

const char Http_Encoding_Chunked[]

String value of TE for indicating chunked encoding

const char Http_Header_AuthenticationInfo[]

String value of HTTP header field, AuthorizationInfo

const char Http_Header_Authorization[]

String value of HTTP header field, Authorization

const char Http_Header_CacheControl[]

String value of HTTP header field, Cache-Control

const char Http_Header_Connection[]

String value of HTTP header field, Connection

const char Http_Header_ContentLength[]

String value of HTTP header field, Content-Length

const char Http_Header_ContentRange[]

String value of HTTP header field Content Range

const char Http_Header_ContentType[]

String value of HTTP header field, Content-Type

const char Http_Header_Expect[]

String value of HTTP header field, Expect

const char Http_Header_Server[]

String value of HTTP header field, name of the server

const char Http_Header_TransferEncoding[]

String value of HTTP header field, Transfer Encoding

const char Http_Method_Delete[]

String value of HTTP DELETE request method

const char Http_Method_Get[]

String value of HTTP GET request method

const char Http_Method_Head[]

String value of HTTP HEAD request method

const char Http_Method_Post[]

String value of HTTP POST request method

const char Http_Method_Put[]

String value of HTTP PUT request method

const char Http_Method_Unknown[]

String value of an unknown HTTP request method

const char Http_NewLine[]

String value of CR-LF pairs

const char Http_Protocol_V10[]

String value of HTTP protocol HTTP 1.0

const char Http_Protocol_V11[]

String value of HTTP protocol HTTP 1.1

const char Http_Range_Bytes[]

String value for "bytes"

const char Http_Space[]

String value of space(SP)


All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:45 by doxygen 1.8.8