justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.93k stars 618 forks source link

Question: 304 #756

Closed myangelkamikaze closed 4 years ago

myangelkamikaze commented 4 years ago

Response body is not read yet. Use SessionEventArgs.GetResponseBody() or SessionEventArgs.GetResponseBodyAsString() method to read the response body. at Titanium.Web.Proxy.Http.Response.EnsureBodyAvailable(Boolean throwWhenNotReadYet) at Titanium.Web.Proxy.EventArguments.SessionEventArgs.GetResponseBody(CancellationToken cancellationToken)

(I have no idea how to post a stack trace)

I've been getting this exception when trying to read the response body in the BeforeResponse handler. The exception makes no real sense because I'm always using GetResponseBody. What I did notice after a while is that this only happens on response status 304.

Is it possible that GetResponseBody is failing because of 304?

honfika commented 4 years ago

Yes, it is because of 304.... it has no body.

myangelkamikaze commented 4 years ago

If it's not too much work, would it be possible to add a better exception for cases like this? Though this issue might be enough already. Thanks for the clarification!

honfika commented 4 years ago

Added: https://github.com/justcoding121/Titanium-Web-Proxy/commit/f2076892c676ba5e8ca1627e9984da1f75612b26

honfika commented 4 years ago

I close this issue.. feel free to reopen if needed.