FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
Parse_And_Process_HTTP_Stream Class Reference

Scan HTTP and parse stream for HTTP requests/responses. More...

#include <read_file.hpp>

+ Inheritance diagram for Parse_And_Process_HTTP_Stream:

Public Types

enum  ParseState { READ_RESPONSE =1, READ_REQUEST, READ_HEADER_LINE, READ_CONTENT_BODY }
 

Public Member Functions

 Parse_And_Process_HTTP_Stream (size_t maxDocSize=1024 *128, ParseState initialState=READ_RESPONSE)
 
virtual ~Parse_And_Process_HTTP_Stream ()
 
const char * findHeaderAttribute (const char *headerElement) const
 
virtual int processHTTPresponse (unsigned char *line, size_t lineLen)
 User-exit for HTTP response line. More...
 
virtual int processHTTPrequest (unsigned char *line, size_t lineLen)
 User-exit for HTTP request line. More...
 
virtual int processHTTPheader (unsigned char *line, size_t lineLen)
 User exit for HTTP header line. More...
 
virtual int_fast32_t processBlock (unsigned char *blockStart, size_t blockLen) VIRTUAL_OVERRIDE
 User-exit to process block of raw data. More...
 
int processDocument (unsigned char *docStart, size_t docLen) VIRTUAL_OVERRIDE
 User-exit to process extracted document. More...
 
- Public Member Functions inherited from Extract_And_Process_Document_Stream
 Extract_And_Process_Document_Stream (const char *docStart, const char *endTag, size_t maxDocSize=1024 *128)
 
virtual ~Extract_And_Process_Document_Stream ()
 
int scanAndProcessBuffer (const unsigned char *block, size_t blockLen)
 
int scanAndProcessBuffer (File_Buffer *bfrState)
 
int addIOblockThenProcess (SharedBufferAllocRecord *rec, IO_Processor *controller)
 Specialized interface to add incoming block from BufferRegion maintained by an IO_Processor. Block content is appended and then returned before any processing of the content is attempted. More...
 

Public Attributes

char httpVersion [16]
 
char statusCode [8]
 
char responseReason [48]
 
char httpRequest [16]
 
char requestURL [1024]
 
int32_t contentLengthWanted
 
std::map< std::string, std::string > headerAttributes
 

Protected Attributes

ParseState parseState
 
ParseState restartParseState
 
- Protected Attributes inherited from Extract_And_Process_Document_Stream
enum Extract_And_Process_Document_Stream:: { ... }  scanState
 
enum Extract_And_Process_Document_Stream:: { ... }  restartScanState
 
unsigned char documentStartPrefix [64]
 
unsigned char documentEndTag [64]
 
File_BufferpendingContent
 
ssize_t neededBlockLen
 
size_t documentStartLen
 
size_t documentEndLen
 

Additional Inherited Members

- Protected Types inherited from Extract_And_Process_Document_Stream
enum  { FIND_NOTHING =0, FIND_DOC_START =1, FIND_END_TAG =2, FIND_BLOCK_LENGTH =3 }
 
- Protected Member Functions inherited from Extract_And_Process_Document_Stream
int scanForDocument ()
 

Detailed Description

Scan HTTP and parse stream for HTTP requests/responses.

Member Enumeration Documentation

◆ ParseState

Enumerator
READ_RESPONSE 
READ_REQUEST 
READ_HEADER_LINE 
READ_CONTENT_BODY 

Constructor & Destructor Documentation

◆ Parse_And_Process_HTTP_Stream()

Parse_And_Process_HTTP_Stream::Parse_And_Process_HTTP_Stream ( size_t  maxDocSize = 1024*128,
ParseState  initialState = READ_RESPONSE 
)
inlineexplicit

◆ ~Parse_And_Process_HTTP_Stream()

virtual Parse_And_Process_HTTP_Stream::~Parse_And_Process_HTTP_Stream ( )
inlinevirtual

Member Function Documentation

◆ findHeaderAttribute()

const char* Parse_And_Process_HTTP_Stream::findHeaderAttribute ( const char *  headerElement) const
inline

◆ processBlock()

virtual int_fast32_t Parse_And_Process_HTTP_Stream::processBlock ( unsigned char *  blockStart,
size_t  blockLen 
)
inlinevirtual

User-exit to process block of raw data.

Will be invoked if processDocument() returns a value greater than 0.

Reimplemented from Extract_And_Process_Document_Stream.

Reimplemented in HTTP_SessionRecord.

◆ processDocument()

int Parse_And_Process_HTTP_Stream::processDocument ( unsigned char *  docStart,
size_t  docLen 
)
inlinevirtual

User-exit to process extracted document.

Returns
Number of bytes of required for a subsequent block of raw data.
Return values
0indicates no block of raw data is required.
-1indicates some error.

Implements Extract_And_Process_Document_Stream.

References contentLengthWanted, io(), LOG_COMPONENT_CERR, LOG_ENDLINE, parseState, processHTTPheader(), processHTTPrequest(), processHTTPresponse(), READ_CONTENT_BODY, READ_HEADER_LINE, READ_REQUEST, READ_RESPONSE, and restartParseState.

◆ processHTTPheader()

virtual int Parse_And_Process_HTTP_Stream::processHTTPheader ( unsigned char *  line,
size_t  lineLen 
)
inlinevirtual

User exit for HTTP header line.

Default implementation saves lines as key/value pairs in a map. Content-Length automatically recognized to retrieve block of subsequent data.

Reimplemented in HTTP_SessionRecord.

References AS_TEXT_BUFFER, contentLengthWanted, headerAttributes, io(), LOG_COMPONENT_CERR, LOG_ENDLINE, and text2uint32().

Referenced by processDocument(), and HTTP_SessionRecord::processHTTPheader().

◆ processHTTPrequest()

virtual int Parse_And_Process_HTTP_Stream::processHTTPrequest ( unsigned char *  line,
size_t  lineLen 
)
inlinevirtual

User-exit for HTTP request line.

Default implementation parses HTTP request line, which is expected to appear like: "GET / HTTP/1.1"

References AS_TEXT_BUFFER, headerAttributes, httpRequest, httpVersion, io(), LOG_COMPONENT_CERR, LOG_ENDLINE, and requestURL.

Referenced by processDocument().

◆ processHTTPresponse()

virtual int Parse_And_Process_HTTP_Stream::processHTTPresponse ( unsigned char *  line,
size_t  lineLen 
)
inlinevirtual

User-exit for HTTP response line.

Default implementation parses response line, which is expected to appear like "HTTP/1.1 200 OK"

References AS_TEXT_BUFFER, headerAttributes, httpVersion, io(), LOG_COMPONENT_CERR, LOG_ENDLINE, responseReason, and statusCode.

Referenced by processDocument().

Member Data Documentation

◆ contentLengthWanted

int32_t Parse_And_Process_HTTP_Stream::contentLengthWanted

◆ headerAttributes

std::map<std::string,std::string> Parse_And_Process_HTTP_Stream::headerAttributes

◆ httpRequest

char Parse_And_Process_HTTP_Stream::httpRequest[16]

◆ httpVersion

char Parse_And_Process_HTTP_Stream::httpVersion[16]

◆ parseState

ParseState Parse_And_Process_HTTP_Stream::parseState
protected

◆ requestURL

char Parse_And_Process_HTTP_Stream::requestURL[1024]

◆ responseReason

char Parse_And_Process_HTTP_Stream::responseReason[48]

◆ restartParseState

ParseState Parse_And_Process_HTTP_Stream::restartParseState
protected

◆ statusCode

char Parse_And_Process_HTTP_Stream::statusCode[8]

The documentation for this class was generated from the following file:
Generated: Fri Jul 31 2020 18:19:16
Support Information