dodo  0.0.1
A C++ library to create containerized Linux services
dodo::network::protocol::http::HTTPFragment Class Referenceabstract

Generic HTTP fragment, either a complete (such as HTTPRequest) or incomplete HTTP fragment (ssuch as a HTTPRequest::HTTPRequestLine) . More...

#include <httpfragment.hpp>

Inheritance diagram for dodo::network::protocol::http::HTTPFragment:

Data Structures

struct  ParseResult
 Used to convey parsing succces. More...
 

Public Types

enum  ParseError : unsigned int {
  peOk = 0, peIncomplete, peSystemError, peExpectCRLF,
  peUnFinishedToken, peExpectingHeaderColon, peInvalidHeaderFieldValue, peInvalidHeaderListEnd,
  peInvalidMethod, peInvalidHTTPVersion, peInvalidRequestLine, peInvalidContentLength,
  peUnexpectedBody, peInvalidTransferEncoding, peInvalidChunkHex, peInvalidLastChunk,
  peExpectingUnsignedInt
}
 Parse results returned by the parse functions. More...
 

Public Member Functions

virtual std::string asString () const =0
 Convert the HTTPFragment in a HTTP protocol string. More...
 
virtual ParseResult parse (VirtualReadBuffer &buffer)=0
 Read a complete HTTPFragment from a VirtualReadBuffer. More...
 

Static Public Member Functions

static std::string getParseResultAsString (ParseError error)
 Return the string description of a ParseError. More...
 

Detailed Description

Generic HTTP fragment, either a complete (such as HTTPRequest) or incomplete HTTP fragment (ssuch as a HTTPRequest::HTTPRequestLine) .

Descendant classes implement ParseResult parse( VirtualReadBuffer& buffer ) to extract a complete HTTP fragment. Note that the buffer is expected to be blocking on reads, if the HTTPFragment expects more data it will wait and in case of a read timeout, fail. If the parse fails due to incomplete data within the timeout, the ParseResult return value is { peSystemError, common::SystemError::ecEAGAIN }.

Definition at line 45 of file httpfragment.hpp.

Member Enumeration Documentation

◆ ParseError

Parse results returned by the parse functions.

Enumerator
peOk 

Ok.

peIncomplete 

Not an error, but more data is expected to complete.

peSystemError 

The parse failed due to system error SocketReadBuffer::getLastError()

peExpectCRLF 

A CR was not followed by an LF.

peUnFinishedToken 

A token is being parsed but is ending erroneously.

peExpectingHeaderColon 

A header field name was read, but no colon found after it.

peInvalidHeaderFieldValue 

A header field value was being read, but it is invalid.

peInvalidHeaderListEnd 

A header list is not ending properly.

peInvalidMethod 

An invalid method was specified in the request line.

peInvalidHTTPVersion 

An invalid HTTP version was specified in the request line.

peInvalidRequestLine 

The request line is invalid.

peInvalidContentLength 

The content length does not match the message body size.

peUnexpectedBody 

A message body is present but should not be there.

peInvalidTransferEncoding 

The specified transfer-encoding header is invalid.

peInvalidChunkHex 

The hex chunk size is invalid.

peInvalidLastChunk 

The last chunk does not have size 0.

peExpectingUnsignedInt 

An unsigned int was expected.

Definition at line 51 of file httpfragment.hpp.

Member Function Documentation

◆ asString()

virtual std::string dodo::network::protocol::http::HTTPFragment::asString ( ) const
pure virtual

◆ getParseResultAsString()

std::string dodo::network::protocol::http::HTTPFragment::getParseResultAsString ( ParseError  error)
static

Return the string description of a ParseError.

Parameters
errorThe ParseError to describe.
Returns
The ParseError description.

Definition at line 37 of file httpfragment.cpp.

References peExpectCRLF, peExpectingHeaderColon, peExpectingUnsignedInt, peIncomplete, peInvalidChunkHex, peInvalidContentLength, peInvalidHeaderFieldValue, peInvalidHeaderListEnd, peInvalidHTTPVersion, peInvalidLastChunk, peInvalidMethod, peInvalidRequestLine, peInvalidTransferEncoding, peOk, peSystemError, peUnexpectedBody, and peUnFinishedToken.

Referenced by dodo::network::protocol::http::HTTPFragment::ParseResult::asString().

Here is the caller graph for this function:

◆ parse()


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