SNode.C
Loading...
Searching...
No Matches
web::http::decoder::Chunked Class Reference

#include <Chunked.h>

Inheritance diagram for web::http::decoder::Chunked:
Collaboration diagram for web::http::decoder::Chunked:

Classes

class  Chunk
 

Public Member Functions

 Chunked (const core::socket::stream::SocketContext *socketContext)
 
 Chunked (const Chunked &)=delete
 
 Chunked (Chunked &&) noexcept=default
 
Chunkedoperator= (const Chunked &)=delete
 
Chunkedoperator= (Chunked &&) noexcept=default
 
- Public Member Functions inherited from web::http::ContentDecoder
 ContentDecoder ()=default
 
 ContentDecoder (const ContentDecoder &)=delete
 
 ContentDecoder (ContentDecoder &&) noexcept=default
 
ContentDecoderoperator= (const ContentDecoder &)=delete
 
ContentDecoderoperator= (ContentDecoder &&) noexcept=default
 
virtual ~ContentDecoder ()
 
bool isComplete () const
 
bool isError () const
 
std::vector< char > && getContent ()
 

Private Member Functions

std::size_t read () override
 

Private Attributes

const core::socket::stream::SocketContextsocketContext
 
Chunk chunk
 
int state = 0
 

Additional Inherited Members

- Protected Attributes inherited from web::http::ContentDecoder
std::vector< char > content
 
bool completed = false
 
bool error = false
 

Detailed Description

Definition at line 61 of file Chunked.h.

Constructor & Destructor Documentation

◆ Chunked() [1/3]

web::http::decoder::Chunked::Chunked ( const core::socket::stream::SocketContext socketContext)
explicit

Definition at line 54 of file Chunked.cpp.

56 }
const core::socket::stream::SocketContext * socketContext
Definition Chunked.h:113

References socketContext.

Referenced by web::http::Parser::analyzeHeader().

Here is the caller graph for this function:

◆ Chunked() [2/3]

web::http::decoder::Chunked::Chunked ( const Chunked )
delete

◆ Chunked() [3/3]

web::http::decoder::Chunked::Chunked ( Chunked &&  )
defaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

Chunked & web::http::decoder::Chunked::operator= ( Chunked &&  )
defaultnoexcept

◆ operator=() [2/2]

Chunked & web::http::decoder::Chunked::operator= ( const Chunked )
delete

◆ read()

std::size_t web::http::decoder::Chunked::read ( )
overrideprivatevirtual

Implements web::http::ContentDecoder.

Definition at line 58 of file Chunked.cpp.

58 {
59 std::size_t consumed = 0;
60 std::size_t ret = 0;
61
62 switch (state) {
63 case -1:
64 content.clear();
65 completed = false;
66 error = false;
67
68 state = 0;
69
70 [[fallthrough]];
71 case 0:
72 do {
74 consumed += ret;
75
76 if (chunk.isComplete()) {
77 content.insert(content.end(), chunk.begin(), chunk.end());
78
79 completed = chunk.size() == 0;
80
81 } else if (chunk.isError()) {
82 error = true;
83 }
84
85 state = (completed || error) ? -1 : state;
86 } while (ret > 0 && !completed);
87 break;
88 }
89
90 return consumed;
91 }
std::vector< char > content
std::size_t read(const core::socket::stream::SocketContext *socketContext)
Definition Chunked.cpp:96
std::vector< char >::iterator begin()
Definition Chunked.cpp:215
std::vector< char >::iterator end()
Definition Chunked.cpp:219

References web::http::decoder::Chunked::Chunk::begin(), chunk, web::http::ContentDecoder::completed, web::http::ContentDecoder::content, web::http::decoder::Chunked::Chunk::end(), web::http::ContentDecoder::error, web::http::decoder::Chunked::Chunk::isComplete(), web::http::decoder::Chunked::Chunk::isError(), web::http::decoder::Chunked::Chunk::read(), web::http::decoder::Chunked::Chunk::size(), socketContext, and state.

Here is the call graph for this function:

Member Data Documentation

◆ chunk

Chunk web::http::decoder::Chunked::chunk
private

Definition at line 115 of file Chunked.h.

Referenced by read().

◆ socketContext

const core::socket::stream::SocketContext* web::http::decoder::Chunked::socketContext
private

Definition at line 113 of file Chunked.h.

Referenced by Chunked(), and read().

◆ state

int web::http::decoder::Chunked::state = 0
private

Definition at line 117 of file Chunked.h.

Referenced by read().


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