curlhttp-headers

cURL and etag usage?


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

Solution

  • 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"'