Skip to content

Commit

Permalink
add minimal implementation of chunked parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cmazakas committed Jul 3, 2024
1 parent bca23dd commit 4c7b154
Show file tree
Hide file tree
Showing 8 changed files with 752 additions and 12 deletions.
6 changes: 5 additions & 1 deletion include/boost/http_proto/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ enum class condition
{
/** More input data is required.
*/
need_more_input
need_more_input,

/** The parsed body contained invalid octets
*/
invalid_payload
};

} // http_proto
Expand Down
2 changes: 2 additions & 0 deletions include/boost/http_proto/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ class BOOST_SYMBOL_VISIBLE
std::uint64_t body_avail_;
std::uint64_t body_total_;
std::uint64_t payload_remain_;
std::size_t chunk_remain_ = 0;
std::size_t nprepare_;

buffers::flat_buffer fb_;
Expand All @@ -407,6 +408,7 @@ class BOOST_SYMBOL_VISIBLE
bool got_eof_;
// bool need_more_;
bool head_response_;
bool needs_chunk_close_ = false;
};

//------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ message(
{
default:
case condition::need_more_input: return "need more input";
case condition::invalid_payload: return "invalid body octets received";
}
}

Expand All @@ -118,9 +119,12 @@ equivalent(
{
switch(static_cast<condition>(code))
{
case condition::invalid_payload:
return (ec == error::bad_payload);

case condition::need_more_input:
if( ec == urls::grammar::error::need_more ||
ec == error::need_data)
ec == error::need_data )
return true;
break;

Expand Down
Loading

0 comments on commit 4c7b154

Please sign in to comment.