{"action":"closed","issue":{"url":"https://api.github.com/repos/Azure/autorest/issues/769","repository_url":"https://api.github.com/repos/Azure/autorest","labels_url":"https://api.github.com/repos/Azure/autorest/issues/769/labels{/name}","comments_url":"https://api.github.com/repos/Azure/autorest/issues/769/comments","events_url":"https://api.github.com/repos/Azure/autorest/issues/769/events","html_url":"https://github.com/Azure/autorest/issues/769","id":137640483,"number":769,"title":"Streaming large streams results in an OutOfMemoryException (in C#, Python, Java)","user":{"login":"matthchr","id":8798850,"avatar_url":"https://avatars.githubusercontent.com/u/8798850?v=3","gravatar_id":"","url":"https://api.github.com/users/matthchr","html_url":"https://github.com/matthchr","followers_url":"https://api.github.com/users/matthchr/followers","following_url":"https://api.github.com/users/matthchr/following{/other_user}","gists_url":"https://api.github.com/users/matthchr/gists{/gist_id}","starred_url":"https://api.github.com/users/matthchr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthchr/subscriptions","organizations_url":"https://api.github.com/users/matthchr/orgs","repos_url":"https://api.github.com/users/matthchr/repos","events_url":"https://api.github.com/users/matthchr/events{/privacy}","received_events_url":"https://api.github.com/users/matthchr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Azure/autorest/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/Azure/autorest/labels/java","name":"java","color":"b07219"},{"url":"https://api.github.com/repos/Azure/autorest/labels/python","name":"python","color":"3572A5"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-01T17:43:15Z","updated_at":"2016-04-15T23:45:31Z","closed_at":"2016-04-15T23:45:31Z","body":"The generated code which issues a request currently does this:\r\n`_httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);`\r\n\r\nThe problem with doing this is that HttpClient's default behavior is to read the entire response into memory, which causes an out of memory exception if the response stream is large enough (for example in the case of large file downloads).\r\n\r\nIn methods which return `Stream`, this should be changed to be: `_httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);`\n<!---@tfsbridge:{\"tfsId\":5867564}-->"}}