The maximum number of bytes to write using TransmitFile cannot be
greater than INT_MAX - 1, otherwise the function fails with WSAEINVAL.
https://docs.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock-transmitfile
The issue can be reproduced using the http-server-sync example, by
sending a GET request for a file larger than INTMAX.
e.g:
$ curl -v http://127.0.0.1:8080/ubuntu.iso -o ubuntu.iso
* Trying 127.0.0.1:8080...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /ubuntu.iso HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.83.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Boost.Beast/330
< Content-Type: application/text
< Content-Length: 3654957056
<
{ [0 bytes data]
* transfer closed with 3654957056 bytes remaining to read
0 3485M 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Closing connection 0
curl: (18) transfer closed with 3654957056 bytes remaining to read
Signed-off-by: Petre Pircalabu <ppircalabu@bitdefender.com>
The missing error check leads to completely ignoring the body limit,
as the body limit is compared to the "Content-Length" header inside
the "finish_header" method.
closes#2201
API Changes:
`string_param`, which was previously the argument type when setting field values
has been replaced by `string_view`. Because of this, it is no longer possible to
set message field values directly as integrals.
Users are required to convert numeric arguments to a string type prior to calling
`fields::set` et. al.
Beast provides the non-allocating `to_static_string()` function for this purpose.
To set Content-Length field manually, call `message::content_length`.
fixes#1956
API Changes:
The signature of basic_parser<>::body_limit(n) has changed. It now accepts an
optional std::uint64_t. The caller may indicate that no body limit is required
by calling body_limit(boost::none). The default limits remain in place in order
to maintain 'safe by default' behaviour.
closes#1897closes#1965
C++14 or later is required to support completion tokens that use
per-operation return type deduction. For C++11, a completion
token's async_result specialisation must still provide the nested
typedef `return_type`.
clang complains about missing initializer (even though the field was
properly initialized by the default constructor).
Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
`asio::coroutine` is an extension, which is not part of
the Networking TS, so the `net` alias is not appropriate in this case.
Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
The `temporary_buffer<A>` class template replaces the use of
`static_string` in `http::fields`, simplifying `set_chunked_impl` and
`set_keep_alive_impl`.
Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
Not using lambdas in this case reduced the number of instantiations of
the algorithm by a factor of 4x at no (observable) runtime cost.
Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
fix: #1567
std::byte is not an arithmetic type, which caused compilation to fail
when it was used in vector_body.
Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
close#1574
This change yields a modest performance improment of 1-2% by replacing
the exception-based handling of buffer overflow with one based on
regular conditional checks.
Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>