{"action":"created","issue":{"url":"https://api.github.com/repos/boostorg/beast/issues/1223","repository_url":"https://api.github.com/repos/boostorg/beast","labels_url":"https://api.github.com/repos/boostorg/beast/issues/1223/labels{/name}","comments_url":"https://api.github.com/repos/boostorg/beast/issues/1223/comments","events_url":"https://api.github.com/repos/boostorg/beast/issues/1223/events","html_url":"https://github.com/boostorg/beast/issues/1223","id":349734378,"node_id":"MDU6SXNzdWUzNDk3MzQzNzg=","number":1223,"title":"async_read() on body doesn't return bytes_transferred when need_buffer is set","user":{"login":"rhashimoto","id":156154,"node_id":"MDQ6VXNlcjE1NjE1NA==","avatar_url":"https://avatars2.githubusercontent.com/u/156154?v=4","gravatar_id":"","url":"https://api.github.com/users/rhashimoto","html_url":"https://github.com/rhashimoto","followers_url":"https://api.github.com/users/rhashimoto/followers","following_url":"https://api.github.com/users/rhashimoto/following{/other_user}","gists_url":"https://api.github.com/users/rhashimoto/gists{/gist_id}","starred_url":"https://api.github.com/users/rhashimoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhashimoto/subscriptions","organizations_url":"https://api.github.com/users/rhashimoto/orgs","repos_url":"https://api.github.com/users/rhashimoto/repos","events_url":"https://api.github.com/users/rhashimoto/events{/privacy}","received_events_url":"https://api.github.com/users/rhashimoto/received_events","type":"User","site_admin":false},"labels":[{"id":458528982,"node_id":"MDU6TGFiZWw0NTg1Mjg5ODI=","url":"https://api.github.com/repos/boostorg/beast/labels/Bug","name":"Bug","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-11T13:32:35Z","updated_at":"2018-11-27T18:20:45Z","closed_at":null,"author_association":"NONE","body":"I'm using the v124 branch because Debian is still back at Boost 62, but it looks like this behavior may also be on the trunk.\r\n\r\nI'm using [`http::async_read()`](https://www.boost.org/doc/libs/1_68_0/libs/beast/doc/html/beast/ref/boost__beast__http__async_read/overload1.html) with a parser to read a request body. I wrote a custom [`Body`](https://www.boost.org/doc/libs/1_68_0/libs/beast/doc/html/beast/concepts/Body.html) but it is very similar to [`buffer_body`](https://www.boost.org/doc/libs/1_68_0/libs/beast/doc/html/beast/ref/boost__beast__http__buffer_body.html), only using different storage. When the request body is larger than the capacity of my `Body::value_type`, my `Body::writer` (v124 is before the reader/writer swap) fills up the buffer and sets `need_buffer`. I can see that `Body::writer::put()` returns the size of the buffer, but my `http::async_read()` handler returns 0.\r\n\r\nI believe that the problem is [here](https://github.com/boostorg/beast/blob/v124/include/boost/beast/http/impl/read.ipp#L307) (in v124) and [here](https://github.com/boostorg/beast/blob/develop/include/boost/beast/http/impl/read.ipp#L313) (on the trunk). In `http::detail::read_op<>::operator()`, updating `bytes_transferred` is skipped when the underlying read returns an error. Patching my local read.ipp to move the update before the error check gives me the behavior I expect - the handler's size argument is set to the buffer size. I don't know whether this simple fix is correct for all cases, though.\r\n\r\nA workaround is to check whether `ec == boost::beast::http::need_buffer` in the handler and if so  override the size argument with the buffer size."},"comment":{"url":"https://api.github.com/repos/boostorg/beast/issues/comments/442163476","html_url":"https://github.com/boostorg/beast/issues/1223#issuecomment-442163476","issue_url":"https://api.github.com/repos/boostorg/beast/issues/1223","id":442163476,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MjE2MzQ3Ng==","user":{"login":"vinniefalco","id":1503976,"node_id":"MDQ6VXNlcjE1MDM5NzY=","avatar_url":"https://avatars3.githubusercontent.com/u/1503976?v=4","gravatar_id":"","url":"https://api.github.com/users/vinniefalco","html_url":"https://github.com/vinniefalco","followers_url":"https://api.github.com/users/vinniefalco/followers","following_url":"https://api.github.com/users/vinniefalco/following{/other_user}","gists_url":"https://api.github.com/users/vinniefalco/gists{/gist_id}","starred_url":"https://api.github.com/users/vinniefalco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinniefalco/subscriptions","organizations_url":"https://api.github.com/users/vinniefalco/orgs","repos_url":"https://api.github.com/users/vinniefalco/repos","events_url":"https://api.github.com/users/vinniefalco/events{/privacy}","received_events_url":"https://api.github.com/users/vinniefalco/received_events","type":"User","site_admin":false},"created_at":"2018-11-27T18:20:45Z","updated_at":"2018-11-27T18:20:45Z","author_association":"MEMBER","body":"Apologies for taking so long with this. I have done a thorough investigation and determined that Asio has set the precedent that when a non-success error code is indicated, the rest of the return values should be meaningful. I am applying the fix as you suggested, which passes tests and looks like an uncontroversial improvement."}}
{"actor":{"display_login":"vinniefalco"}}