Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL and etag usage?

Tags:

how would I send an etag over cURL? also can cURL save the etag like it does with COOKIEJAR?

from the headers i see this

my GET request

GET /Vpreviews/p/8b329b598fcdad4fd33432e78128da48f7219882.fll?    e=1332973900&ri=4500&rs=75&h=bca0ce28998e637f27cf1d5c7042e7a0 HTTP/1.1 Host: veoh-139.vo.llnwd.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 DNT: 1 Connection: keep-alive 

server response

HTTP/1.1 200 OK Server: Veoh-1.5 (lighttpd-1.4.18) Content-Type: video/x-flv Accept-Ranges: bytes Etag: "8b329b598fcdad4fd33432e78128da48f72198829640882" User-Header: X-llnw-rate-limit: ri=4500, rs=98 Age: 162476 Date: Wed, 28 Mar 2012 22:06:41 GMT Last-Modified: Sun, 01 Jan 2012 13:29:44 GMT Expires: Mon, 27 Mar 2017 06:02:35 GMT Content-Length: 9640882 Connection: keep-alive 
like image 732
Frank Ly Avatar asked Mar 29 '12 06:03

Frank Ly


People also ask

What is ETag curl?

December 6, 2019 Daniel Stenberg. The ETag HTTP response header is an identifier for a specific version of a resource. It lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.

What is ETag used for?

An entity tag (ETag) is an HTTP header used for Web cache validation and conditional requests from browsers for resources. Etags use persistent identification elements (PIE) that have been tagged to the user's browser.

How do you use curl?

To make a GET request using Curl, run the curl command followed by the target URL. Curl automatically selects the HTTP GET request method unless you use the -X, --request, or -d command-line option.


1 Answers

Take a look at this Railscast. In the show notes, you can see examples of using curl to grab a page with cookies and ETags.

Basically, you pass it in with a 'If-None-Match' header:

curl -I http://localhost:3000/books/1 --header 'If-None-Match: "0f46357eafa5c719e8e3bf277a993e07"' 
like image 76
dkam Avatar answered Sep 20 '22 01:09

dkam