I have written an REST API and I'm try to test a request that has no Accept header. If I send a request via Curl it adds a default header Accept: */*
, you can see this if you add Curl's -v parameter.
Is there are way to send a request via Curl with no Accept header?
Servers may ignore the Accept header. If you're not returning anything in your response, it's kind of meaningless. It's up to you to decide whether you want to reject requests with Accept headers or not.
Curl by default adds headers such as Content-type and User-agent .
To send an HTTP header with a Curl request, you can use the -H command-line option and pass the header name and value in "Key: Value" format. If you do not provide a value for the header, this will remove the standard header that Curl would otherwise send. The number of HTTP headers is unlimited.
To send the Content-Type header using Curl, you need to use the -H command-line option. For example, you can use the -H "Content-Type: application/json" command-line parameter for JSON data. Data is passed to Curl using the -d command-line option. It must match the provided content type.
Pass in a header with no value on the right side of the colon to have that removed from the request, even if curl otherwise would add it by itself.
curl -H 'Accept:' http://example.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With