Open edwvee opened 3 years ago
You could try using https://pkg.go.dev/github.com/valyala/fasthttp?utm_source=godoc#Server.HeaderReceived
Its ugly but you could potentially reject the request by setting MaxRequestBodySize
to 1
for example.
I would also be open to a pull request that adds something to https://pkg.go.dev/github.com/valyala/fasthttp?utm_source=godoc#RequestConfig to reject the request at that point.
But I have a client, not a server.
Added a code using the net/http to achieve what I need as an example.
@erikdubbelboer, such a feature will be useful! I guess I have a patch for this, to skip downloading in case mime type in headers not expected, but not inside the actual body, but need to check.
If you have something that works and you can make a pull request that would be great!
but it works like skip body if unwanted header met, and not allows to download body in chunks and check it for mime type
For example, I want to stop downloading content if it has wrong mime type. How can I do so? The documentation shows only
resp.Body()
which gets whole response. Below is how I use standard http library: