boostorg / boostorg/beast

async_read_header needs documentation and example code

Open
#1,432 6 comments 0 reactions 1 assignee Claimed by @madmongo1 View on GitHub
Doc
Dominant language
C++
Stars
4.8k
Forks
694
Avg merge
12h 48m
Merged PRs (30d)
1

Description

beast version: 181
compiler: VS2017 15.8.8

Got an error when used async_read_header() like this:
```c++
#include
#include

void main()
{
namespace http = boost::beast::http;
using tcp = boost::asio::ip::tcp;

boost::asio::io_context ioc;
tcp::socket s{ ioc };
boost::beast::flat_buffer buffer{ 8192 };
http::request req;
http::request_header<> req_header;

http::async_read_header(
s, buffer, req_header, [](const auto & error, auto length){});

http::async_read_header(
s, buffer, req, [](const auto & error, auto length) {});
}
```
Error:
```
1>------ Build started: Project: beast_wrapper, Configuration: Debug Win32 ------
1>beast_wrapper.cpp
1>beast_wrapper.cpp(258): error C2672: 'boost::beast::http::async_read_header': no matching overloaded function found
1>beast_wrapper.cpp(259): error C2784: '::boost::asio::async_result<::boost::asio::decay::type,void(boost::beast::error_code,size_t)>::return_type boost::beast::http::async_read_header(AsyncReadStream &,DynamicBuffer &,boost::beast::http::basic_parser &,ReadHandler &&)': could not deduce template argument for 'boost::beast::http::basic_parser &' from 'boost::beast::http::header'
1> with
1> [
1> Fields=boost::beast::http::fields
1> ]
1>\boost_1_68_0\boost\beast\http\read.hpp(386): note: see declaration of 'boost::beast::http::async_read_header'
1>beast_wrapper.cpp(261): error C2672: 'boost::beast::http::async_read_header': no matching overloaded function found
1>beast_wrapper.cpp(262): error C2784: '::boost::asio::async_result<::boost::asio::decay::type,void(boost::beast::error_code,size_t)>::return_type boost::beast::http::async_read_header(AsyncReadStream &,DynamicBuffer &,boost::beast::http::basic_parser &,ReadHandler &&)': could not deduce template argument for 'boost::beast::http::basic_parser &' from 'boost::beast::http::message'
1>\boost_1_68_0\boost\beast\http\read.hpp(386): note: see declaration of 'boost::beast::http::async_read_header'
1>Done building project "beast_wrapper.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
```
What am I doing wrong, should it work with both request and request_header?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.