NuriaProject Framework  0.1
The NuriaProject Framework
Public Member Functions | List of all members
Nuria::HttpParser Class Reference

Parser functions for the HyperText Transfer Protocol. More...

#include <httpparser.hpp>

Public Member Functions

 HttpParser ()
 
 ~HttpParser ()
 
QByteArray correctHeaderKeyCase (QByteArray key)
 
HttpClient::TransferMode decideTransferMode (HttpClient::HttpVersion version, const QByteArray &connectionHeader)
 
bool parseCookies (const QByteArray &data, HttpClient::Cookies &target)
 
bool parseFirstLine (const QByteArray &data, QByteArray &verb, QByteArray &path, QByteArray &version)
 
bool parseFirstLineFull (const QByteArray &line, HttpClient::HttpVerb &verb, QByteArray &path, HttpClient::HttpVersion &version)
 
bool parseHeaderLine (const QByteArray &data, QByteArray &name, QByteArray &value)
 
bool parseRangeHeaderValue (const QByteArray &value, qint64 &begin, qint64 &end)
 
HttpClient::HttpVerb parseVerb (const QByteArray &verb)
 
HttpClient::HttpVersion parseVersion (const QByteArray &version)
 
bool removeTrailingNewline (QByteArray &data)
 

Detailed Description

Parser functions for the HyperText Transfer Protocol.

Constructor & Destructor Documentation

Nuria::HttpParser::HttpParser ( )

Constructor.

Nuria::HttpParser::~HttpParser ( )

Destructor.

Member Function Documentation

QByteArray Nuria::HttpParser::correctHeaderKeyCase ( QByteArray  key)

Takes a key name of a http header and 'corrects' the case, so 'content-length' becomes 'Content-Length'.

HttpClient::TransferMode Nuria::HttpParser::decideTransferMode ( HttpClient::HttpVersion  version,
const QByteArray &  connectionHeader 
)

Returns the appropriate HttpClient::TransferMode for connectionHeader. Defaults to HttpClient::Streaming.

bool Nuria::HttpParser::parseCookies ( const QByteArray &  data,
HttpClient::Cookies target 
)

Parses data from a 'Cookie' header sent by the client and puts the result into target. Returns true on success.

bool Nuria::HttpParser::parseFirstLine ( const QByteArray &  data,
QByteArray &  verb,
QByteArray &  path,
QByteArray &  version 
)

Parses the first line from a HTTP request header from data and lets verb, path and version point to the specific parts in data. Returns true on success.

bool Nuria::HttpParser::parseFirstLineFull ( const QByteArray &  line,
HttpClient::HttpVerb verb,
QByteArray &  path,
HttpClient::HttpVersion version 
)

Parses the first line of a HTTP header in line. The results are put into verb, path and version. If any parser step fails, false is returned.

bool Nuria::HttpParser::parseHeaderLine ( const QByteArray &  data,
QByteArray &  name,
QByteArray &  value 
)

Parses a single HTTP header line from data and puts the result into name and value. Returns true on success.

bool Nuria::HttpParser::parseRangeHeaderValue ( const QByteArray &  value,
qint64 &  begin,
qint64 &  end 
)

Parses value which contains the value of a "Range" HTTP header. On success, it sets begin and end to the given values and returns true.

HttpClient::HttpVerb Nuria::HttpParser::parseVerb ( const QByteArray &  verb)

Tries to parse verb. Returns HttpClient::InvalidVerb if verb didn't match any known HTTP verb.

HttpClient::HttpVersion Nuria::HttpParser::parseVersion ( const QByteArray &  version)

Tries to parse version. Returns HttpClient::HttpUnknown if version didn't match any known version string.

bool Nuria::HttpParser::removeTrailingNewline ( QByteArray &  data)

Removes trailing newline characters according to HTTP. Returns false if there were no newline characters.


The documentation for this class was generated from the following file: