#include <XrdHttpHeaderUtils.hh>
Static Public Member Functions | |
| static ssize_t | parseContentLength (const std::string &value) |
| static void | parseReprDigest (const std::string &value, std::map< std::string, std::string > &output) |
| static int | parseTransferEncoding (const std::string &value) |
| static void | parseWantReprDigest (const std::string &value, std::map< std::string, uint8_t > &output) |
Definition at line 31 of file XrdHttpHeaderUtils.hh.
|
static |
Parses the value of a 'Content-Length' HTTP header.
The HTTP spec says Content-Length must be one or more decimal digits with no sign character and no whitespace inside the number. Anything else is malformed and must be rejected with HTTP 400, because if we trust a garbage Content-Length we may disagree with a proxy in front of us on where the request body ends — which is the basis of HTTP request smuggling attacks.
Trailing whitespace and CRLF in the value are tolerated (parseLine forwards the raw header line including the closing \r
).
Reference: RFC 9112 §6.2 (Content-Length syntax) and RFC 7230 §3.3.3 rule 4 (rejection of invalid values).
| value | the raw value of the Content-Length header |
Definition at line 110 of file XrdHttpHeaderUtils.cc.
Referenced by XrdHttpReq::parseLine().
|
static |
Parses the 'Repr-Digest' header value received from the client Syntax: "Repr-Digest: adler=:base64EncodedValue:, crc32=:base64EncodedValue:
| value | contains the value of the header Repr-Digest |
| output | the map containing the digests and their associated base64 encoded values |
Definition at line 35 of file XrdHttpHeaderUtils.cc.
References base64DecodeHex(), XrdOucTUtils::splitString(), and XrdOucUtils::trim().
Referenced by XrdHttpReq::parseLine().
|
static |
Parses the value of a 'Transfer-Encoding' HTTP header.
Transfer-Encoding carries a comma-separated list of body encodings, for example "chunked" or "gzip, chunked". The list is case-insensitive and items can have whitespace around them.
The only encoding this server speaks is "chunked". HTTP requires that whenever "chunked" appears it must be the LAST item in the list (because that is the one that determines how the body is framed on the wire).
This function checks two things together: that "chunked" is actually present (matched case-insensitively as a whole token, not as a substring like the old code did), and that it is the last item.
Trailing CRLF on the last item is tolerated.
Reference: RFC 9112 §6.1 (Transfer-Encoding syntax and the "chunked-must-be-last" rule) and RFC 7230 §3.3.1 (same rule).
| value | the raw value of the Transfer-Encoding header |
Definition at line 136 of file XrdHttpHeaderUtils.cc.
References XrdOucTUtils::splitString(), and XrdOucUtils::trim().
Referenced by XrdHttpReq::parseLine().
|
static |
Parses 'Want-Repr-Digest' header value received from the client Syntax: "Want-Repr-Digest: adler=1, crc32=2, sha-256=9 The values are integers representing the preference, comprised between 0 and 9.
| value | contains the value of the header Want-Repr-Digest |
| output | the map containing the lower-cased digest name and the associated preference |
Definition at line 73 of file XrdHttpHeaderUtils.cc.
References XrdOucUtils::touint8_t(), and XrdOucUtils::trim().
Referenced by XrdHttpReq::parseLine().