{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Home/issues/3476","repository_url":"https://api.github.com/repos/aspnet/Home","labels_url":"https://api.github.com/repos/aspnet/Home/issues/3476/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Home/issues/3476/comments","events_url":"https://api.github.com/repos/aspnet/Home/issues/3476/events","html_url":"https://github.com/aspnet/Home/issues/3476","id":355281344,"node_id":"MDU6SXNzdWUzNTUyODEzNDQ=","number":3476,"title":"HttpClient does not work with Request.EnableRewind","user":{"login":"Tratcher","id":1821173,"node_id":"MDQ6VXNlcjE4MjExNzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1821173?v=4","gravatar_id":"","url":"https://api.github.com/users/Tratcher","html_url":"https://github.com/Tratcher","followers_url":"https://api.github.com/users/Tratcher/followers","following_url":"https://api.github.com/users/Tratcher/following{/other_user}","gists_url":"https://api.github.com/users/Tratcher/gists{/gist_id}","starred_url":"https://api.github.com/users/Tratcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tratcher/subscriptions","organizations_url":"https://api.github.com/users/Tratcher/orgs","repos_url":"https://api.github.com/users/Tratcher/repos","events_url":"https://api.github.com/users/Tratcher/events{/privacy}","received_events_url":"https://api.github.com/users/Tratcher/received_events","type":"User","site_admin":false},"labels":[{"id":1039529641,"node_id":"MDU6TGFiZWwxMDM5NTI5NjQx","url":"https://api.github.com/repos/aspnet/Home/labels/area-System.Net.Http","name":"area-System.Net.Http","color":"ededed","default":false},{"id":85297674,"node_id":"MDU6TGFiZWw4NTI5NzY3NA==","url":"https://api.github.com/repos/aspnet/Home/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-29T18:30:59Z","updated_at":"2018-08-29T18:31:06Z","closed_at":null,"author_association":"MEMBER","body":"_From @cnblogs-dudu on August 21, 2018 9:39_\n\nPerhaps it is `HttpConnection.WriteAsync` does not work with `FileBufferingReadStream`.\r\n\r\nWebsite A with the following code is listening 5000.\r\n```cs\r\npublic class HomeController : Controller\r\n{\r\n    public async Task<IActionResult> Index()\r\n    {\r\n        Request.EnableRewind();\r\n        var streamContent = new StreamContent(Request.Body);\r\n        var httpClient = new HttpClient();\r\n        var response = await httpClient.PostAsync(\"http://localhost:5002\", streamContent);\r\n        return Ok(await response.Content.ReadAsStringAsync());\r\n    }\r\n}\r\n```\r\nWebsite B with the following code is listening 5002.\r\n```cs\r\npublic class HomeController : Controller\r\n{\r\n    public async Task<IActionResult> Index()\r\n    {\r\n        using (var ms = new MemoryStream())\r\n        {\r\n            await Request.Body.CopyToAsync(ms);\r\n            return Ok(ms.Length);\r\n        }\r\n    }\r\n}\r\n```\r\nUse the following curl command to send a request.\r\n```shell\r\ncurl -s -d 'test' localhost:5000/\r\n```\r\nThe actual output is 0. The expected output is 4.\r\n\r\nIf remove `Request.EnableRewind()`, it works.\r\nIf put the following code between `Request.EnableRewind()` and `HttpClient` , it works.\r\n```cs\r\nusing (var ms = new MemoryStream())\r\n{\r\n    await Request.Body.CopyToAsync(ms);\r\n}\r\nRequest.Body.Seek(0, 0);\r\n```\n\n_Copied from original issue: dotnet/corefx#31866_"},"comment":{"url":"https://api.github.com/repos/aspnet/Home/issues/comments/417058099","html_url":"https://github.com/aspnet/Home/issues/3476#issuecomment-417058099","issue_url":"https://api.github.com/repos/aspnet/Home/issues/3476","id":417058099,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzA1ODA5OQ==","user":{"login":"Tratcher","id":1821173,"node_id":"MDQ6VXNlcjE4MjExNzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1821173?v=4","gravatar_id":"","url":"https://api.github.com/users/Tratcher","html_url":"https://github.com/Tratcher","followers_url":"https://api.github.com/users/Tratcher/followers","following_url":"https://api.github.com/users/Tratcher/following{/other_user}","gists_url":"https://api.github.com/users/Tratcher/gists{/gist_id}","starred_url":"https://api.github.com/users/Tratcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tratcher/subscriptions","organizations_url":"https://api.github.com/users/Tratcher/orgs","repos_url":"https://api.github.com/users/Tratcher/repos","events_url":"https://api.github.com/users/Tratcher/events{/privacy}","received_events_url":"https://api.github.com/users/Tratcher/received_events","type":"User","site_admin":false},"created_at":"2018-08-29T18:31:06Z","updated_at":"2018-08-29T18:31:06Z","author_association":"MEMBER","body":"_From @cnblogs-dudu on August 25, 2018 14:32_\n\n`return length > 0` only works in the sample app. It does not works in our production scenario that putting file to cloud storage.\r\n\r\nI fixed it in HttpAbstractions repo. I will submit a PR to HttpAbstractions."}}
{"actor":{"display_login":"Tratcher"}}