How to display request headers with command line curl

curl’s -v or –verbose option shows the HTTP request headers, among other things. Here is some sample output: $ curl -v http://google.com/ * About to connect() to google.com port 80 (#0) * Trying 66.102.7.104… connected * Connected to google.com (66.102.7.104) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.16.4 (i386-apple-darwin9.0) libcurl/7.16.4 OpenSSL/0.9.7l zlib/1.2.3 > … Read more

How do I measure request and response times at once using cURL?

From this brilliant blog post… https://blog.josephscott.org/2011/10/14/timing-details-with-curl/ cURL supports formatted output for the details of the request (see the cURL manpage for details, under -w, –write-out <format>). For our purposes we’ll focus just on the timing details that are provided. Times below are in seconds. Create a new file, curl-format.txt, and paste in: time_namelookup: %{time_namelookup}s\n time_connect: … Read more

How do I get a YouTube video thumbnail from the YouTube API?

Each YouTube video has four generated images. They are predictably formatted as follows: https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg https://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (i.e., one of 1.jpg, 2.jpg, 3.jpg) is: https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg For the high quality version of the thumbnail use a … Read more

How do I POST JSON data with cURL?

You need to set your content-type to application/json. But -d (or –data) sends the Content-Type application/x-www-form-urlencoded, which is not accepted on Spring’s side. Looking at the curl man page, I think you can use -H (or –header): -H “Content-Type: application/json” Full example: curl –header “Content-Type: application/json” \ –request POST \ –data ‘{“username”:”xyz”,”password”:”xyz”}’ \ http://localhost:3000/api/login (-H … Read more