Open shkreios opened 4 years ago
This is because fasthttp always wants to set a Content-Type header for non GET/HEAD requests: https://github.com/valyala/fasthttp/blob/aa3f96c883322033099b4466c151893a3f9c2172/header.go#L1593-L1595
It is currently not possible to disable this.
Maybe it would work for you to set the Content-Type
to text/plain
?
@erikdubbelboer Thank you for your answer. text/plain
does not work but the app strangely accepts application/json
even if the body is empty. Do you think it will be possible to disable this in the future? Because I want to use fashttp as reverse proxy and it is not possible for me to create a "failover" for all potentially wrong set Content-Type
headers.
Thanks again for your time.
For ResponseHeader
we have ResponseHeader.SetNoDefaultContentType()
. I think we should add something similar for RequestHeader
.
Hey, I just started to learn golang as well as fashttp. I tried to build a fasthttp reverse proxy using this libary and later using the code from this issue.
All requests work without any problems, only on delete requests the hostclient adds the header
content-type
with the valueapplication/x-www-form-urlencoded
.The server to which the request is proxyed responds with
406
, is there a way to disable this behavior?Thank you in advance for any help.
Code example: In the code example I don't use a proxy just the
fashttp.Client
to make a request with the request method set toDELETE
. I have tested the behavior with a fashttp and express server, the code is shown below.sender.go
Output:
receiver.go
Output:
Express JS Server example
server.js
Output: