The Traffic Server API HTTP header functions enable you to work with HTTP header data stored in marshal buffers.
The HTTP header data structure is a parsed version of the HTTP header defined in the HTTP protocol specification. An HTTP header is composed of a request or response line followed by zero or more MIME fields. In fact, an HTTP header is a subclass of a MIME header; all of the MIME header routines operate on HTTP headers.
An HTTP request line is composed of a method, a URL, and version. A response line is composed of a version, status code, and reason phrase. See About HTTP Headers for additional details and examples.
To facilitate fast comparisons and reduce storage size, Traffic Server defines several pre-allocated method names. These names correspond to the methods defined in the HTTP 1.1 specification
Pre-Allocated Method Names | HTTP 1.1 Method |
INK_HTTP_METHOD_CONNECT |
"CONNECT" |
INK_HTTP_METHOD_DELETE |
"DELETE" |
INK_HTTP_METHOD_GE |
"GET" |
INK_HTTP_METHOD_HEAD |
"HEAD" |
INK_HTTP_METHOD_ICP_QUERY |
"ICP_QUERY" |
INK_HTTP_METHOD_OPTIONS |
"OPTIONS" |
INK_HTTP_METHOD_POST |
"POST" |
INK_HTTP_METHOD_PURGE |
"PURGE" |
INK_HTTP_METHOD_PUT |
"PUT" |
INK_HTTP_METHOD_TRACE |
"TRACE" |
Traffic Server also defines several common values that appear in HTTP headers.
Traffic Server Definition | HTTP Header Value |
INK_HTTP_VALUE_BYTES |
"bytes" |
INK_HTTP_VALUE_CHUNKED |
"chunked" |
INK_HTTP_VALUE_CLOSE |
"close" |
INK_HTTP_VALUE_COMPRESS |
"compress" |
INK_HTTP_VALUE_DEFLATE |
"deflate" |
INK_HTTP_VALUE_GZIP |
"gzip" |
INK_HTTP_VALUE_IDENTITY |
"identity" |
INK_HTTP_VALUE_KEEP_ALIVE |
"keep-alive" |
INK_HTTP_VALUE_MAX_AGE |
"max-age" |
INK_HTTP_VALUE_MAX_STALE |
"max-stale" |
INK_HTTP_VALUE_MIN_FRESH |
"min-fresh" |
INK_HTTP_VALUE_MUST_REVALIDATE |
"must-revalidate" |
INK_HTTP_VALUE_NONE |
"none" |
INK_HTTP_VALUE_NO_CACHE |
"no-cache" |
INK_HTTP_VALUE_NO_STORE |
"no-store" |
INK_HTTP_VALUE_NO_TRANSFORM |
"no-transform" |
INK_HTTP_VALUE_ONLY_IF_CACHED |
"only-if-cached" |
INK_HTTP_VALUE_PRIVATE |
"private" |
INK_HTTP_VALUE_PROXY_REVALIDATE |
"proxy-revalidate" |
INK_HTTP_VALUE_PUBLIC |
"public" |
INK_HTTP_VALUE_S_MAX_AGE |
"s-maxage" |
The method names and header values above are defined in
InkAPI.h
as const char*
strings. When
Traffic Server sets a method or a header value, it checks to make sure that the new value is one of the known values. If it is, then it stores a pointer into a global table (instead of
storing the known value in the marshal buffer). The method names and header values listed above are also
pointers into this table. This allows simple pointer comparison of the
value returned from INKHttpMethodGet
with one of
the values listed above. It is also recommended that you use the above
values when referring to one of the known schemes, since this removes
the possibility of a spelling error.
The HTTP header functions are:
INKHttpHdrClone
INKHttpHdrCopy
INKHttpHdrCreate
INKHttpHdrDestroy
INKHttpHdrLengthGet
INKHttpHdrMethodGet
INKHttpHdrMethodSet
INKHttpHdrPrint
INKHttpHdrReasonGet
INKHttpHdrReasonLookup
INKHttpHdrReasonSet
INKHttpHdrStatusGet
INKHttpHdrStatusSet
INKHttpHdrTypeGet
INKHttpHdrTypeSet
INKHttpHdrUrlGet
INKHttpHdrUrlSet
INKHttpHdrVersionGet
INKHttpHdrVersionSet
INKHttpParserClear
INKHttpParserCreate
INKHttpParserDestroy
INKHttpHdrParseReq
INKHttpHdrParseResp