Tldr: Bug in curl.md

Created on 8 Jun 2017  路  11Comments  路  Source: tldr-pages/tldr

I have found a wrong command in curl.md, though I'm not sure if this goes for all platforms. The -I flag does not show just the headers, instead it performs a HEAD request. -i shows the headers, but not just the headers, also the response body.

Could others have a look at how their curl operates?

page edit

Most helpful comment

I'd rather keep those two separate, for clarity -- see the discussion in #1396.

My suggestion is either we remove the -I or replace it by -v...

I suppose it makes sense to remove -I from this example, since it's not directly connected to it. It could be used in a separate example, but we've ran out of space for this page, and -I is probably less fundamental than the examples already present on the page.

All 11 comments

curl is likely the page with most edits we have :) The most relevant PR seems to be #1240 ("add -I parameter to show header information", by @stoneo), but also pinging @jeremyruppel (from #291), @bobstrecansky (from #696) and @ericbn (from #1019/#1023).

For me, curl -I and curl -i show headers, but -i show response body too. So I don't know better description than current one.

Yeah, looks like both BSD curl and GNU curl have -I as the HEAD request. Maybe giving an example with -v for verbose, that also shows headers for request and response, could be a more generally useful.

Agreed. I've used -I extensively when I just want to see the response header. -v gives you a lot more, and you can always save the whole output with -o if you want to inspect the body. -i should be used when you want to see the header and the body at the same time.

So are you proposing replacing -i with -v, @ericbn? Or replacing -I instead? We do need to remove something, since we're already at our maximum number of examples for this page.

What about you @bobstrecansky, what change would you propose?

We could rearrange things a little bit:

- Send a request with an extra header using a custom HTTP method:
    curl -H 'X-My-Header: 123' -X PUT http://example.com

- Send data in JSON format, specifying the appropriate content-type header:
    curl -d '{"name":"bob"}' -H 'Content-Type: application/json' http://example.com/users/1234

The above could be merged into one, maybe like:

- Send data, specifying the content-type header and a custom HTTP method:
    curl -d '{"name":"bob"}' -H 'Content-Type: application/json' -X PUT http://example.com/users/1234

As for this one:

- Pass a user name and password for server authentication and show headers info only:
    curl -u myusername:mypassword -I http://example.com

My suggestion is either we remove the -I or replace it by -v...

I'd rather keep those two separate, for clarity -- see the discussion in #1396.

My suggestion is either we remove the -I or replace it by -v...

I suppose it makes sense to remove -I from this example, since it's not directly connected to it. It could be used in a separate example, but we've ran out of space for this page, and -I is probably less fundamental than the examples already present on the page.

-I is useful if you don't care about the request method, because it cuts out a lots of the clutter. -v is useful when you do, as it can be used with any request method.

So what do you suggest @sbrl? Unfortunately the space is limited and we won't be able to cover all use cases, so we have to choose which ones to prioritize.

By the way, I hadn't received a notification of the reactions to my comment -- if @sbrl doesn't have objections, it looks like we'd have consensus to go ahead and remove -I from that example.

@waldyrious Yeah, go ahead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phpmaple picture phpmaple  路  3Comments

michaeldbianchi picture michaeldbianchi  路  3Comments

kelthuzadx picture kelthuzadx  路  3Comments

dikarel picture dikarel  路  3Comments

waldyrious picture waldyrious  路  3Comments