Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions example/usage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ inspect_response(corosio::tls_context tls_ctx)
if(ec)
throw std::system_error(ec);

std::cout << "status: " << r.status_int() << '\n';
std::cout << "reason: " << r.reason() << '\n';
std::cout << "headers: " << r.headers() << '\n';
std::cout << "body: " << co_await r.as<std::string>() << '\n';
std::cout << "status: " << r.status_int() << '\n';
std::cout << "reason: " << r.reason() << '\n';
std::cout << "headers:\n" << r.headers();
std::cout << "body: " << co_await r.as<std::string>() << '\n';
// end::inspect_response[]
}

Expand Down
13 changes: 12 additions & 1 deletion include/boost/burl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,26 @@
#define BOOST_BURL_HPP

#include <boost/burl/any_request_body.hpp>
#include <boost/burl/conversion.hpp>
#include <boost/burl/client.hpp>
#include <boost/burl/conversion.hpp>
#include <boost/burl/error.hpp>
#include <boost/burl/fields.hpp>
#include <boost/burl/fields_base.hpp>
#include <boost/burl/file.hpp>
#include <boost/burl/head_parser.hpp>
#include <boost/burl/json.hpp>
#include <boost/burl/message_head_base.hpp>
#include <boost/burl/multipart_form.hpp>
#include <boost/burl/request.hpp>
#include <boost/burl/request_body.hpp>
#include <boost/burl/request_head.hpp>
#include <boost/burl/request_head_base.hpp>
#include <boost/burl/response.hpp>
#include <boost/burl/response_head.hpp>
#include <boost/burl/response_head_base.hpp>
#include <boost/burl/static_fields.hpp>
#include <boost/burl/static_request_head.hpp>
#include <boost/burl/static_response_head.hpp>
#include <boost/burl/string.hpp>
#include <boost/burl/urlencoded_form.hpp>

Expand Down
9 changes: 4 additions & 5 deletions include/boost/burl/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <boost/burl/cookie_jar.hpp>
#include <boost/burl/detail/config.hpp>
#include <boost/burl/detail/connection_pool.hpp>
#include <boost/burl/fields.hpp>
#include <boost/burl/request.hpp>
#include <boost/burl/response.hpp>

Expand All @@ -21,8 +22,6 @@
#include <boost/capy/io_task.hpp>
#include <boost/corosio/endpoint.hpp>
#include <boost/corosio/tls_context.hpp>
#include <boost/http/field.hpp>
#include <boost/http/fields.hpp>
#include <boost/url/url.hpp>
#include <boost/url/url_view.hpp>

Expand Down Expand Up @@ -315,7 +314,7 @@ class client
private:
config config_;
std::shared_ptr<detail::connection_pool> pool_;
http::fields headers_;
fields headers_;
burl::cookie_jar cookie_jar_;

public:
Expand Down Expand Up @@ -388,7 +387,7 @@ class client
c.headers().set(http::field::user_agent, "BoostBurl/1.0");
@endcode
*/
http::fields&
fields_base&
headers() noexcept
{
return headers_;
Expand All @@ -401,7 +400,7 @@ class client
precedence over default headers with the
same name.
*/
const http::fields&
const fields_base&
headers() const noexcept
{
return headers_;
Expand Down
36 changes: 10 additions & 26 deletions include/boost/burl/detail/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define BOOST_BURL_DETAIL_PARSER_HPP

#include <boost/burl/error.hpp>
#include <boost/burl/head_parser.hpp>
#include <boost/burl/detail/circular_buffer.hpp>

#include <boost/capy/buffers/buffer_copy.hpp>
Expand All @@ -19,10 +20,7 @@
#include <boost/capy/io_task.hpp>
#include <boost/capy/read.hpp>
#include <boost/http/concept/buffer_source.hpp>
#include <boost/http/message_base.hpp>
#include <boost/http/header_limits.hpp>
#include <boost/http/static_response.hpp>
#include <boost/http/static_request.hpp>
#include <boost/http/metadata.hpp>

#include <memory>

Expand Down Expand Up @@ -56,7 +54,7 @@ class parser

struct config
{
http::header_limits hdr_limits;
header_limits hdr_limits;

std::size_t in_buffer = 64 * 1024;
std::size_t dec_buffer = 8 * 1024;
Expand Down Expand Up @@ -106,7 +104,7 @@ class parser

parser(
config const& cfg,
http::detail::kind kind,
bool is_request,
capy::any_read_stream stream = {});

parser(parser&& other) noexcept = default;
Expand All @@ -124,10 +122,10 @@ class parser
void
start(bool head);

http::static_response const&
burl::response_head_base const&
get_response() const;

http::static_request const&
burl::request_head_base const&
get_request() const;

private:
Expand All @@ -145,9 +143,6 @@ class parser
std::size_t
payload_rem() const noexcept;

std::size_t
table_reserve() const noexcept;

capy::io_task<>
refill();

Expand All @@ -165,31 +160,20 @@ class parser
do_read_some(
std::span<capy::mutable_buffer const> buffers);

struct header_deleter
{
void
operator()(
http::detail::header* h) const noexcept
{
::operator delete(h);
}
};

using header_ptr = std::unique_ptr<
http::detail::header, header_deleter>;

http::header_limits hdr_limits_;
capy::any_read_stream stream_;
header_ptr h_;
std::unique_ptr<char[]> buf_;
head_parser hp_;
decoder * dec_ = nullptr;
circular_buffer in_;
circular_buffer out_;
std::uint64_t chunk_rem_ = 0;
std::uint64_t transferred_ = 0;
std::uint64_t decoded_ = 0;
std::uint64_t body_limit_ = 0;
std::uint64_t payload_size_ = 0;
std::error_code dec_err_;
http::payload payload_ = http::payload::none;
bool is_req_ = true;
bool head_ = false;
bool started_ = false;
bool got_header_ = false;
Expand Down
6 changes: 2 additions & 4 deletions include/boost/burl/detail/request_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include <boost/burl/detail/parser.hpp>

#include <boost/http/static_request.hpp>

#include <utility>

namespace boost
Expand All @@ -33,7 +31,7 @@ class request_parser
request_parser(
config const& cfg,
capy::any_read_stream stream = {})
: parser(cfg, http::detail::kind::request, std::move(stream))
: parser(cfg, true, std::move(stream))
{
}

Expand All @@ -48,7 +46,7 @@ class request_parser
parser::start(false);
}

http::static_request const&
burl::request_head_base const&
get() const
{
return get_request();
Expand Down
6 changes: 2 additions & 4 deletions include/boost/burl/detail/response_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include <boost/burl/detail/parser.hpp>

#include <boost/http/static_response.hpp>

#include <utility>

namespace boost
Expand All @@ -33,7 +31,7 @@ class response_parser
response_parser(
config const& cfg,
capy::any_read_stream stream = {})
: parser(cfg, http::detail::kind::response, std::move(stream))
: parser(cfg, false, std::move(stream))
{
}

Expand All @@ -48,7 +46,7 @@ class response_parser
parser::start(head);
}

http::static_response const&
burl::response_head_base const&
get() const
{
return get_response();
Expand Down
Loading
Loading