Transcript from the "Curl" Lesson
>> We've been using Netcat to make these requests, but it's pretty long winded, pretty difficult way of making requests to HTTP servers. There's a command that's available on, I think should probably already be installed on your system. If it's not, I highly recommend that you install it. It's called curl.
[00:00:18] In curl is a really easy way of sending HTTP requests. So the default way that curl works is it will print out the contents of an HTTP request to standard out. So here you can try that with any URL that you want. If my website's running, then yep, I get back a bunch HTML.
[00:00:42] I don't get back the headers, I just get back the content. But if you want the headers as well, you can do capital I and it will only print out the headers and the response. So this is really useful if you need to debug an HTTP server that you're working on and you only care about the headers and you don't wanna have to write out long form with Netcat the actual request or like parse it with some regex, or something.
[00:01:08] Some other things I think I will print out the headers in addition to the content and all kinds of other fun things that you can try. The small s is to get rid of a really annoying progress bar that's printed to standard error that I pretty much never want, unless I'm downloading a big file which I'd probably use wget for that anyways, cuz it can use HTTP range headers to continue the download, but.
[00:01:36] If you wanna always use little s, you could setup an alias for it in your bashrc. Probably not the worst idea. If you wanna o specify the HTTP verb with the curl command you can use -X. So here, we can send a POST request. The default is to send a GET request, but we can send a POST request like this.
[00:02:03] So you do -X POST, the URL. And then for each of those URL encoded form parameters, you can use -d and then you specify the name of the form element and equals sign and the value. So if I use that example from before, our example server we were just using, let's see.
[00:02:25] So here, our server's running again. And now, I can use curl to send that request and it works just the same. So I get back an ok response from the server and curl is smart enough to know how to print out documents that have been encoding with transfer encoding chunked.
[00:02:45] So all that I see is the ok and we can see that the server was able to parse our form upload successfully.