nnl::http::Header Class Reference

Http header. More...

#include <http_header.hh>

List of all members.

Public Member Functions

 Header ()
 Constructor.
void Init ()
 Initialize.
bool Parse (std::string &data)
 Parse header.
std::string & Compose (std::string &buffer)
 Compose header.
Accessors.
const std::string & Method () const
 Get http method.
ssize_t ContentLength () const
 Get content length.
const std::string & Connection () const
 Get connection.
const std::string & FirstLine () const
 Get first line.
bool Complete () const
 Get completion status.
Modifiers.
void Method (const std::string &x)
 Set http method.
void Uri (const std::string &x)
 Set http uri.
void Version (const std::string &x)
 Set version.
void Connection (const std::string &x)
 Set connection.
void ContentLength (ssize_t x)
 Set content length.
void FirstLine (const std::string &x)
 Set first line.
void ContentType (const std::string &x)
 Set content type.
void Custom (const std::string &x)
 Set custom header.

Static Public Attributes

static const ssize_t NO_CONTENT_LENGTH = -1
 content length undefined

Private Member Functions

void ParseFirstLineReq (const std::string &line, std::string::size_type pos, std::string::size_type n)
 Parse first line of the request.
void ParseFirstLineRsp (const std::string &line, std::string::size_type pos, std::string::size_type n)
 Parse first line of the response.

Private Attributes

std::string mMethod
 http method
std::string mUri
 http uri
std::string mVersion
 http version
ssize_t mContentLength
 content length
std::string mConnection
 connection
std::string mContentType
 content type
std::list< std::string > mCustom
 custom header (not including end-of-line)
std::string mProtocolRsp
 response protocol
int mRspCode
 response code
std::string mRspText
 response text
std::string mFirstLine
 first line of either request or response
bool mComplete
 true if header parsing is complete


Detailed Description

Http header.


Constructor & Destructor Documentation

nnl::http::Header::Header (  ) 

Constructor.

Calls Init().


Member Function Documentation

bool nnl::http::Header::Complete (  )  const

Get completion status.

Returns true if header parsing is complete.

Returns:
mComplete

std::string& nnl::http::Header::Compose ( std::string &  buffer  ) 

Compose header.

Compose header from member attributes, store the data in buffer.

Parameters:
buffer where to compose the header
Returns:
ref to buffer

void nnl::http::Header::Connection ( const std::string &  x  ) 

Set connection.

Parameters:
x connection

const std::string& nnl::http::Header::Connection (  )  const

Get connection.

Returns:
mConnection

void nnl::http::Header::ContentLength ( ssize_t  x  ) 

Set content length.

Parameters:
x content length

ssize_t nnl::http::Header::ContentLength (  )  const

Get content length.

Returns:
mContentLength

void nnl::http::Header::ContentType ( const std::string &  x  ) 

Set content type.

Parameters:
x content type

void nnl::http::Header::Custom ( const std::string &  x  ) 

Set custom header.

Append custom header to the list of custom headers.

Parameters:
x header line without the terminating CR LF

void nnl::http::Header::FirstLine ( const std::string &  x  ) 

Set first line.

Parameters:
x first line

const std::string& nnl::http::Header::FirstLine (  )  const

Get first line.

Returns:
mFirstLine

void nnl::http::Header::Init (  ) 

Initialize.

Clear all member attributes.

void nnl::http::Header::Method ( const std::string &  x  ) 

Set http method.

Parameters:
x http method

const std::string& nnl::http::Header::Method (  )  const

Get http method.

Returns:
mMethod

bool nnl::http::Header::Parse ( std::string &  data  ) 

Parse header.

Parse chunk of data and try to create header.

Parameters:
data data to parse
Returns:
true if header complete

void nnl::http::Header::ParseFirstLineReq ( const std::string &  line,
std::string::size_type  pos,
std::string::size_type  n 
) [private]

Parse first line of the request.

The first line of the request is broken to method, uri and version.

Parameters:
line buffer to parse
pos start position
n length

void nnl::http::Header::ParseFirstLineRsp ( const std::string &  line,
std::string::size_type  pos,
std::string::size_type  n 
) [private]

Parse first line of the response.

The first line of the response is broken down to protocol, code and text.

Parameters:
line buffer to parse
pos start position
n length

void nnl::http::Header::Uri ( const std::string &  x  ) 

Set http uri.

Parameters:
x uri

void nnl::http::Header::Version ( const std::string &  x  ) 

Set version.

Parameters:
x version


The documentation for this class was generated from the following file:
Generated on Tue Jun 19 10:31:48 2012 for nnl by  doxygen 1.4.7