Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

HttpHeader

 

struct HttpHeader

This simple structure simplifies parsing of HTTP request and response headers. It is also capable of parsing SCGI requests.

 


 

String first_line

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, Stringfields

Http fields as key-value pairs. Keys are converted to lower-case. Note that the same key can be present multiple times.

 


 

VectorMap<String, HttpCookiecookies

Set of http response http cookies (filled based on Set-Cookie headers during parsing).

 


 

bool scgi

Indicates that this header is a result of parsing scgi.

 


 

String operator[](const char *idconst

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 *idconst

Returns the value of first cookie of response (set by Set-Cookie) with name id.

 


 

bool Response(String& protocol, int& code, String& reasonconst

Returns first line fields of http response.

 


 

bool Request(String& method, String& uri, String& versionconst

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.

 


 

void Clear()

Clears data.

 


 

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.

 


 

HttpHeader()

Default constructor.

 

Last edit by cxl on 05/15/2016. Do you want to contribute?. T++