Hacker News new | past | comments | ask | show | jobs | submit login
A curl cheat sheet (haxx.se)
124 points by fcambus on Sept 17, 2015 | hide | past | favorite | 24 comments



Not strictly a curl hack, but you can quickly get your IP geolocation details with curl and http://ipinfo.io (full disclosure, it's my service):

  $ curl ipinfo.io
  {
    "ip": "208.54.39.206",
    "hostname": "mce2736d0.tmodns.net",
    "city": "Los Angeles",
    "region": "California",
    "country": "US",
    "loc": "34.0522,-118.2437",
    "org": "AS21928 T-Mobile USA, Inc.",
    "postal": "90013",
    "phone": 213
  }
  
Or just your IP

  $ curl ipinfo.io/ip
  208.54.39.206
  
Or any other field (eg. city)

  $ curl ipinfo.io/city
  Los Angeles
  
Or lookup another IP

  $ curl ipinfo.io/8.8.8.8
  {
    "ip": "8.8.8.8",
    "hostname": "google-public-dns-a.google.com",
    "city": "Mountain View",
    "region": "California",
    "country": "US",
    "loc": "37.3860,-122.0838",
    "org": "AS15169 Google Inc.",
    "postal": "94040",
    "phone": 650
  }
Or a specific field for that IP:

  $ curl ipinfo.io/8.8.8.8/org
  AS15169 Google Inc.


If you start a comment out with "not strictly [related to linked article]" and hijack the discussion by plugging a website it seems like the decent thing to do is mention that you are the developer behind said website. I think this is even more important when you include so much <pre> text that the other comments are pushed so far down the page.

Full-Disclosure: Some people still believe in it


Thanks for the tip. I've updated the comment to add the disclosure. Definitely not my intention to hide it though, it's clearly listed in my profile.


> the decent thing to do is mention that you are the developer behind said website

or just use a fake account ... like anybody else :D


I can't probably count how many times I use this in a week. Thank you very much for this service :)


And I've just spent a bit of time playing with this service. I think that authors should be proud of their work and claim credit up front on HN.


Regardless how good your service could be, this is completely unrelated to the article.


Slightly offtopic, but I highly recommend using httpie for command line http:

https://github.com/jkbrzt/httpie

No cheatsheeet needed, the syntax is a lot friendler.


Found httpie sometime back. I still use curl but 80% of the time I use httpie now.


httpie is the last curl cheatsheet you'll ever need


While great, I stopped using it for httpie instead, it has a much simpler interface.


Maybe I'm wrong, but httpie appears to be targetting http transactions only, while curl supports multiple protocols (ftp, etc.).

curl's syntax is also baked into various Web Browser network debuggers. Both Chrome and Firefox's network transactions display have a "output to curl" option to allow you to recreate the network transaction exactly.

Edit: on Firefox, the option is "Copy as curl"


That is true, curl has some additional protocol features and then of course it being a standard part of most *nix OSes makes it easy to understand why Chrome and Firefox both have the copy as curl option. I still use curl regularly but for any pure http(s) stuff I use httpie because of its improved user experience.


Likewise, I switched over. I just wish HTTPie could have an "output to curl" feature.


I apologize if this is obvious but I do not understand why you wish httpie had an output to curl feature? Am I missing some sarcastic twist?


I'd guess it has something to do with curl being available everywhere and httpie requiring installation. Oftentimes you can't enforce that your preferred alternative is deployed where you'd like to run scripts, so http->curl.


I think they meant that it would useful to have it provide a curl equivalent command, much like chrome has in the network section.


Confessions. I know I should use curl but I never do and just use wget and think curl is just a one year newer wget :(

curl is better tool than wget but I used wget first and never changed. I do use aria2c more now for downloading but I know curl is a great tool I don't use.


May I suggest adding `--proxy URL` which is useful if using Charles/Fiddler to toggle between environments.


I use `HTTP_PROXY=http://xxx curl xxxx` all the way. Works for any program, without need to remember different option syntax.


In my experience the proxy environment variable (contrary to most other environment variables) must be lower case, i.e. “http_proxy”. Therefore:

  http_proxy=http://proxy-server.example:3128/ some_command


You are absolutely right. I stand corrected.


-x is already in there, which is the short version of --proxy...


curl -e "referer"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: