This simple structure simplifies parsing of HTTP request and response headers. It is also capable of parsing SCGI requests.
The first line of request/response - the content of this line is different for response and request.
String f1, f2, f3
First, second and third part of the first line. Content is different for response and request.
VectorMap<String, String> fields
Http fields as key-value pairs. Keys are converted to lower-case. Note that the same key can be present multiple times.
VectorMap<String, HttpCookie> cookies
Set of http response http cookies (filled based on Set-Cookie headers during parsing).
Indicates that this header is a result of parsing scgi.
String operator(const char *id) const
Returns the first http header field with key id (must be lower-case) or empty string if such field is not present.
String GetCookie(const char *id) const
Returns the value of first cookie of response (set by Set-Cookie) with name id.
bool Response(String& protocol, int& code, String& reason) const
Returns first line fields of http response.
bool Request(String& method, String& uri, String& version) const
Returns first line fields of http request.
String GetProtocol() const
Returns the protocol part of of the first line response.
int GetCode() const
Returns the return code part of the first line of response.
String GetReason() const
Returns the reason part of the first line of response.
String GetMethod() const
Returns the method part of the first line of request.
String GetURI() const
Returns the URI part of the first line of request.
String GetVersion() const
Returns the version part of the first line of request.
int64 GetContentLength() const
Returns the content length as specified in header or 0 if not specified or header not yet loaded.
bool ParseAdd(const String& hdrs)
Parses the header (all lines of header) into first_line and fields.
bool Parse(const String& hdrs)
Calls Clear and parses the header (all lines of header) into first_line and fields.
bool ParseSCGI(const String& scgi_hdr)
Parse SCGI header, resulting state is as if the header parsed was normal HTTP.
bool Read(TcpSocket& socket)
Reads the header from socket and parses it. Method detects SCGI requests based on first character of request - if it is a digit, SCGI is assumed and the header is parsed as SCGI.