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 39 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 32 of file Chunked.cpp.

34 }
const core::socket::stream::SocketContext * socketContext
Definition Chunked.h:91

References socketContext.

◆ 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 36 of file Chunked.cpp.

36 {
37 std::size_t consumed = 0;
38 std::size_t ret = 0;
39
40 switch (state) {
41 case -1:
42 content.clear();
43 completed = false;
44 error = false;
45
46 state = 0;
47
48 [[fallthrough]];
49 case 0:
50 do {
52 consumed += ret;
53
54 if (chunk.isComplete()) {
55 content.insert(content.end(), chunk.begin(), chunk.end());
56
57 completed = chunk.size() == 0;
58
59 } else if (chunk.isError()) {
60 error = true;
61 }
62
63 state = (completed || error) ? -1 : state;
64 } while (ret > 0 && !completed);
65 break;
66 }
67
68 return consumed;
69 }
std::vector< char > content
std::size_t read(const core::socket::stream::SocketContext *socketContext)
Definition Chunked.cpp:74
std::vector< char >::iterator begin()
Definition Chunked.cpp:193
std::vector< char >::iterator end()
Definition Chunked.cpp:197

References web::http::ContentDecoder::completed, web::http::ContentDecoder::error, and state.

Member Data Documentation

◆ chunk

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

Definition at line 93 of file Chunked.h.

◆ socketContext

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

Definition at line 91 of file Chunked.h.

Referenced by Chunked().

◆ state

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

Definition at line 95 of file Chunked.h.

Referenced by read().


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