How could I get rid of accept : */* out of reqwest header

Hi

I have made a custom header for my http client with reqwest but it seem add "accept": "/" by default how could I get rid of this header ?

I test the code it always throw 411 error but if I test same request in application like Httpie it has no error

Sounds like we need more information on what the server side is expecting. When using HTTPie it will default to Accept: */* just like reqwest.

You can change the accept header value in reqwest, before sending the HTTP request. Is there a specific "accept" value you need to send?

But maybe the cause of the 411 error is something different, I'd suggest comparing all the request headers between HTTPie and reqwest to see what might be different.

1 Like

here the header and body message for reqwest vs HTTPie. I only notice that accept header is different

POST
/GetPut?TYPE=GET
HTTP/1.1
{"content-length": "103", "content-type": "text; charset=ISO-8859-1", "host": "127.0.0.1", "user-agent": "reqwest", "accept": "/"}
":HEADER\nTABLE=VERSION\nVERSION\nSTRING\n1.00\nTABLE=CURRENT_ATTRIBUTES\nSERIAL_NUM\nSTRING\nAB22D002000XX3Z28\n"

POST
/GetPut?TYPE=GET
HTTP/1.1
{"host": "127.0.0.1", "content-type": "text; charset=ISO-8859-1", "user-agent": "HTTPie", "content-length": "103", "connection": "close"}
":HEADER\nTABLE=VERSION\nVERSION\nSTRING\n1.00\nTABLE=CURRENT_ATTRIBUTES\nSERIAL_NUM\nSTRING\nAAB22D002000XX3Z28\n"

something strange that I test same code in python and it work as expected but always get 411 error when I test with rust

here a simple test python code

import requests

url = "http://127.0.0.1:3000/GetPut"
querystring = {"TYPE":"GET"}
payload = ":HEADER\nTABLE=VERSION\nVERSION\nSTRING\n1.00\nTABLE=CURRENT_ATTRIBUTES\nSERIAL_NUM\nSTRING\nAAB22D002000XX3Z28\n"
headers = {
"User-Agent": "request",
"Host": "127.0.0.1",
"Content-Type": "text/plain; charset=utf-8"
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)

found solution that need to build client manually from client builder and use title_header option

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.