rs / curlie

The power of curl, the ease of use of httpie.
https://curlie.io
MIT License
2.84k stars 95 forks source link

application/json accept header included even when no data passed #60

Open carueda opened 2 years ago

carueda commented 2 years ago

When no explicit Accept header nor any json payload (e.g., foo=bar, quz=42) are specified in the request, the following is a difference in handling wrt httpie:

$ curlie -v get http://example.net
* ...
GET / HTTP/1.1
Host: example.net
User-Agent: curl/7.64.1
Accept: application/json, */*

HTTP/1.1 200 OK
...

That is, curlie includes and gives preference to application/json in the Accept header in these cases. In contrast, httpie simply includes Accept: */*, which seems more flexible in general:

$ http -v get http://example.net
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: example.net
User-Agent: HTTPie/3.2.1
...

fwiw, CURL itself also just includes Accept: */*:

➜  ~ curl -v http://example.net
*   Trying 2606:2800:220:1:248:1893:25c8:1946...
* TCP_NODELAY set
* Connected to example.net (2606:2800:220:1:248:1893:25c8:1946) port 80 (#0)
> GET / HTTP/1.1
> Host: example.net
> User-Agent: curl/7.64.1
> Accept: */*
>
...