Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::HttpMultipartParser Struct Reference

Incremental HTTP multipart/form-data parser. More...

#include <HttpMultipartParser.h>

Public Types

enum class  State {
  Parsing ,
  Result ,
  Finished
}
 State of the parser. More...
 
enum class  Token {
  HeaderName ,
  HeaderValue ,
  PartBody ,
  Boundary ,
  PartHeaderEnd ,
  Finished
}
 One possible Token reported by the parser. More...
 

Public Member Functions

Result initWithBoundary (StringSpan boundary)
 Initializes the parser with the given boundary (that excludes the leading '–')
 
void reset ()
 Resets the parser state.
 
Result parse (Span< const char > data, size_t &readBytes, Span< const char > &parsedData)
 Parse an incoming chunk of bytes, returning actually parsed span.
 

Public Attributes

Token token = Token::Boundary
 Last found result.
 
State state = State::Parsing
 Current state of the parser.
 

Detailed Description

Incremental HTTP multipart/form-data parser.

Member Enumeration Documentation

◆ State

enum class SC::HttpMultipartParser::State
strong

State of the parser.

Enumerator
Parsing 

Parser is parsing.

Result 

Parser is reporting a result.

Finished 

Parser has finished.

◆ Token

enum class SC::HttpMultipartParser::Token
strong

One possible Token reported by the parser.

Enumerator
HeaderName 

Name of a part header has been found.

HeaderValue 

Value of a part header has been found.

PartBody 

A chunk of the part body has been found.

Boundary 

A boundary has been found (start of new part)

PartHeaderEnd 

Headers for the current part have finished.

Finished 

End of all parts.

Member Function Documentation

◆ initWithBoundary()

Result SC::HttpMultipartParser::initWithBoundary ( StringSpan boundary)

Initializes the parser with the given boundary (that excludes the leading '–')

◆ parse()

Result SC::HttpMultipartParser::parse ( Span< const char > data,
size_t & readBytes,
Span< const char > & parsedData )

Parse an incoming chunk of bytes, returning actually parsed span.

Parameters
dataIncoming chunk of bytes to be parsed
readBytesNumber of bytes actually read
parsedDataA sub-span of data pointing at the actually parsed data
Returns
Valid result if parse didn't encounter any error

◆ reset()

void SC::HttpMultipartParser::reset ( )

Resets the parser state.

Member Data Documentation

◆ state

State SC::HttpMultipartParser::state = State::Parsing

Current state of the parser.

◆ token

Token SC::HttpMultipartParser::token = Token::Boundary

Last found result.


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