SNode.C
Loading...
Searching...
No Matches
Chunked.h
Go to the documentation of this file.
1
/*
2
* snode.c - a slim toolkit for network communication
3
* Copyright (C) Volker Christian <me@vchrist.at>
4
* 2020, 2021, 2022, 2023, 2024, 2025
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published
8
* by the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#
ifndef
WEB_HTTP_DECODER_CHUNK_H
21
#
define
WEB_HTTP_DECODER_CHUNK_H
22
23
#
include
"web/http/ContentDecoder.h"
// IWYU pragma: export
24
25
namespace
core::socket::
stream
{
26
class
SocketContext
;
27
}
28
29
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
30
31
#
include
<
cstddef
>
32
#
include
<
string
>
33
#
include
<
vector
>
34
35
#
endif
// DOXYGEN_SHOULD_SKIP_THIS
36
37
namespace
web::http::
decoder
{
38
39
class
Chunked
:
public
web::http::
ContentDecoder
{
// Extends decoder
40
private
:
41
class
Chunk
{
42
public
:
43
Chunk
() =
default
;
44
45
Chunk
(
const
Chunk
&) =
delete
;
46
Chunk
(
Chunk
&&)
noexcept
=
default
;
47
48
Chunk
&
operator
=(
const
Chunk
&) =
delete
;
49
Chunk
&
operator
=(
Chunk
&&)
noexcept
=
default
;
50
51
~
Chunk
();
52
53
inline
std::size_t
read
(
const
core::socket::
stream
::
SocketContext
* socketContext);
54
55
bool
isError
()
const
;
56
bool
isComplete
()
const
;
57
58
std
::
vector
<
char
>::
iterator
begin
();
59
std
::
vector
<
char
>::
iterator
end
();
60
61
std::size_t
size
();
62
63
private
:
64
std
::
vector
<
char
>
chunk
;
65
66
std::string
chunkLenTotalS
;
67
std::size_t
chunkLenTotal
= 0;
68
std::size_t
chunkLenRead
= 0;
69
70
int
state
= 0;
71
72
bool
CR
=
false
;
73
bool
LF
=
false
;
74
75
bool
error
=
false
;
76
bool
completed
=
false
;
77
};
78
79
public
:
80
explicit
Chunked
(
const
core::socket::
stream
::
SocketContext
* socketContext);
81
82
Chunked
(
const
Chunked
&) =
delete
;
83
Chunked
(
Chunked
&&)
noexcept
=
default
;
84
85
Chunked
&
operator
=(
const
Chunked
&) =
delete
;
86
Chunked
&
operator
=(
Chunked
&&)
noexcept
=
default
;
87
88
private
:
89
std::size_t
read
()
override
;
90
91
const
core::socket::
stream
::
SocketContext
*
socketContext
;
92
93
Chunk
chunk
;
94
95
int
state
= 0;
96
};
97
98
}
// namespace web::http::decoder
99
100
#
endif
// WEB_HTTP_DECODER_CHUNK_H
core::socket::stream::SocketContext
Definition
SocketContext.h:42
core::socket::stream::SocketContext::readFromPeer
std::size_t readFromPeer(char *chunk, std::size_t chunklen) const final
Definition
SocketContext.cpp:59
web::http::ContentDecoder
Definition
ContentDecoder.h:32
web::http::ContentDecoder::error
bool error
Definition
ContentDecoder.h:57
web::http::ContentDecoder::completed
bool completed
Definition
ContentDecoder.h:56
web::http::decoder::Chunked::Chunk
Definition
Chunked.h:41
web::http::decoder::Chunked::Chunk::isError
bool isError() const
Definition
Chunked.cpp:185
web::http::decoder::Chunked::Chunk::read
std::size_t read(const core::socket::stream::SocketContext *socketContext)
Definition
Chunked.cpp:74
web::http::decoder::Chunked::Chunk::operator=
Chunk & operator=(Chunk &&) noexcept=default
web::http::decoder::Chunked::Chunk::error
bool error
Definition
Chunked.h:75
web::http::decoder::Chunked::Chunk::operator=
Chunk & operator=(const Chunk &)=delete
web::http::decoder::Chunked::Chunk::size
std::size_t size()
Definition
Chunked.cpp:201
web::http::decoder::Chunked::Chunk::Chunk
Chunk(Chunk &&) noexcept=default
web::http::decoder::Chunked::Chunk::begin
std::vector< char >::iterator begin()
Definition
Chunked.cpp:193
web::http::decoder::Chunked::Chunk::chunkLenTotalS
std::string chunkLenTotalS
Definition
Chunked.h:66
web::http::decoder::Chunked::Chunk::chunkLenTotal
std::size_t chunkLenTotal
Definition
Chunked.h:67
web::http::decoder::Chunked::Chunk::chunkLenRead
std::size_t chunkLenRead
Definition
Chunked.h:68
web::http::decoder::Chunked::Chunk::Chunk
Chunk(const Chunk &)=delete
web::http::decoder::Chunked::Chunk::Chunk
Chunk()=default
web::http::decoder::Chunked::Chunk::isComplete
bool isComplete() const
Definition
Chunked.cpp:189
web::http::decoder::Chunked::Chunk::CR
bool CR
Definition
Chunked.h:72
web::http::decoder::Chunked::Chunk::LF
bool LF
Definition
Chunked.h:73
web::http::decoder::Chunked::Chunk::completed
bool completed
Definition
Chunked.h:76
web::http::decoder::Chunked::Chunk::state
int state
Definition
Chunked.h:70
web::http::decoder::Chunked::Chunk::chunk
std::vector< char > chunk
Definition
Chunked.h:64
web::http::decoder::Chunked::Chunk::end
std::vector< char >::iterator end()
Definition
Chunked.cpp:197
web::http::decoder::Chunked::Chunk::~Chunk
~Chunk()
Definition
Chunked.cpp:71
web::http::decoder::Chunked
Definition
Chunked.h:39
web::http::decoder::Chunked::Chunked
Chunked(const core::socket::stream::SocketContext *socketContext)
Definition
Chunked.cpp:32
web::http::decoder::Chunked::Chunked
Chunked(Chunked &&) noexcept=default
web::http::decoder::Chunked::socketContext
const core::socket::stream::SocketContext * socketContext
Definition
Chunked.h:91
web::http::decoder::Chunked::chunk
Chunk chunk
Definition
Chunked.h:93
web::http::decoder::Chunked::read
std::size_t read() override
Definition
Chunked.cpp:36
web::http::decoder::Chunked::state
int state
Definition
Chunked.h:95
web::http::decoder::Chunked::operator=
Chunked & operator=(Chunked &&) noexcept=default
web::http::decoder::Chunked::Chunked
Chunked(const Chunked &)=delete
web::http::decoder::Chunked::operator=
Chunked & operator=(const Chunked &)=delete
core::socket
Definition
EchoSocketContext.h:26
web::http::decoder
Definition
Chunked.cpp:30
web
http
decoder
Chunked.h
Generated on Mon Feb 10 2025 20:21:59 for SNode.C by
1.11.0