Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send a curl request with no Accept header?

Tags:

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?

like image 357
user86834 Avatar asked Aug 12 '13 09:08

user86834


People also ask

Is Accept header necessary?

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.

Does curl automatically add headers?

Curl by default adds headers such as Content-type and User-agent .

How do you pass header parameters in curl?

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.

How do you pass Content-Type in curl command?

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.


1 Answers

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/
like image 170
Daniel Stenberg Avatar answered Oct 25 '22 19:10

Daniel Stenberg