New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HttpCompletionOption.ResponseHeadersRead with GetJsonAsync<T> = Stream cannot be read exception #794
Comments
ResponseContentRead is the default in Flurl so I don't believe that's related to the exception. Have a look at #474, I think that's more likely the issue here. |
@tmenier The same request to the same URL works correctly if I use ResponseContentRead, but I don't wish to buffer the entire response in memory, so I use ResponseHeadersRead which then produces the exception. The same request with ResponseHeadersRead if I change the code to GetStreamAsync and then manually deserialize it, it works fine, and that's how I worked around it. I think this is definitely not deliberate, so it's probably a bug, because it was working correctly with same code in Flurl 3.0 (which defaulted to ResponseContentRead it seems). I'll take a stab at it at the next opportunity, I think it maybe fixable with small changes only. |
I think a minimal example would help. Please provide a small sample that works in Flurl 3 and not in Flurl 4. I can't think of what might have changed in this area. |
@tmenier I just realized i mistyped in the original issue report and wrote ResponseContentRead instead of ResponseHeadersRead, that's why I got confused by your response. I apologize. I will provide a PR with unit test and will try to fix it as well. I updated the original message. |
…possible to determine this.
Added PR with fix #800 |
…possible to determine this.
Hello,
Flurl.Http: 4.0.0, default system.text.json deserializer, .net 7.0:
Using the GetJsonAsync convenience helper with HttpCompletionOption.ResponseHeadersRead gives an exception when trying to use automatic decompression. The exception is thrown from DeflateStream (Stream cannot be read). In debugger Stream.CanRead is false.
The helper is not properly explicitly reading the response when the response is not yet loaded.
Example API: https://openexchangerates.org/api/
(needs API Key)
The text was updated successfully, but these errors were encountered: