SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
Each HTTP request consists of two parts: the HTTP headers, and HTTP body (which is optional). The headers are standard fields defined by the HTTP RFCs and set various parameters of the HTTP transaction. To allow easy parsing of the headers, they are converted to TLV representation. Each TLV has the structure listed in Table 10-22.
Size | 1 Byte | 2 Bytes | n Bytes |
Name | Metadata Type | Length | Value |
Description | A unique number identifying the HTTP header, see Table 10-23. | Size in bytes of the entire TLV including the Length and Type fields. | Raw value of the HTTP header copied directly from the HTTP request without line termination (\r or \n characters).(1) |
Table 10-23 lists the metadata types.
Metadata Type | HTTP Header Name |
---|---|
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_TYPE | Content-Type |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_LEN | Content-Length |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_LOCATION | Location |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_SERVER | Server |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_USER_AGENT | User-Agent |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_COOKIE | Cookie |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_SET_COOKIE | Set-Cookie |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_UPGRADE | Upgrade |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_REFERER | Referer |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_ACCEPT | Accept |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_ENCODING | Content-Encoding |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_DISPOSITION | Content-Disposition |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONNECTION | Connection |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_ETAG | Etag |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_DATE | Date |
SL_NETAPP_REQUEST_METADATA_TYPE_HEADER_HOST | Host |
SL_NETAPP_REQUEST_METADATA_TYPE_ACCEPT_ENCODING | Accept-Encoding |
SL_NETAPP_REQUEST_METADATA_TYPE_ACCEPT_LANGUAGE | Accept-Language |
SL_NETAPP_REQUEST_METADATA_TYPE_CONTENT_LANGUAGE | Content-Language |
SL_NETAPP_REQUEST_METADATA_TYPE_ORIGIN | Origin |
SL_NETAPP_REQUEST_METADATA_TYPE_ORIGIN_CONTROL_ACCESS | Access-Control-Allow-Origin |
All HTTP headers not in Table 10-23 are skipped. Additionally, the metadata types listed in Table 10-24 are generated internally by the HTTP server to provide more information on the HTTP request.
Metadata Type | Description |
---|---|
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_VERSION | Version field of the HTTP request |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_REQUEST_URI | URI string of the HTTP request |
SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_QUERY_STRING | Query string of the HTTP request |
The TLVs are packed continuously in the metadata section of the request. The user’s code should begin parsing from byte 0, which is always the type field of the first TLV, and finish when metadata-length bytes are processed (which should point to the last byte of the value field of the last TLV). The TLVs are packed in no particular order. Table 10-25 is an example metadata breakout containing two TLVs
Metadata Offset/Content | 0 (TLV1 Type) | 1–2 (TLV1 Length) | 3–10 (TLV1 Value) | 11 (TLV2 Type) | 12–13 (TLV2 Length) | 14–24 (TLV2 Value) |
Data | 1 (HTTP Version) | 11 | “HTTP/1.0” | 19 (Header Host) | 14 | 10.123.45.1 |
An example of how to find and extract the content of a specific TLV from the metadata buffer follows:
_i32 ExtractLengthFromMetaData(_u8 *pMetaDataStart, _u16 MetaDataLen)
{
_u8 *pTlv;
_u8 *pEnd;
_u8 Type;
_u16 TlvLen;
pTlv = pMetaDataStart;
pEnd = pMetaDataStart + MetaDataLen;
while (pTlv < pEnd)
{
Type = *pTlv; /* Type is one byte */
pTlv++;
TlvLen = *(_u16 *)pTlv; /* Length is two bytes */
pTlv+=2;
if (Type == SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_LEN)
{
_i32 LengthFieldValue=0;
/* Found the right type, extract its value and return. */
memcpy(&LengthFieldValue, pTlv, TlvLen);
return LengthFieldValue;
}
else
{
/* Not the type we are looking for. Skip over the
value field to the next type. */
pTlv += TlvLen;
}
}
return -1;
}
/* NetApp request handler*/void NetAppRequestHandler( SlNetAppRequest_t *pNetAppRequest,
SlNetAppResponse_t *pNetAppResponse)
{
_u32 HttpContentLength;
if (pNetAppRequest->requestData.MetadataLen > 0)
{
HttpContentLength = ExtractLengthFromMetaData(
pNetAppRequest->requestData.pMetadata,
pNetAppRequest->requestData.MetadataLen);
}
}