curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Retrieve the correct header for 'Accept-Encoding:' used by the compressed remote resource.

From: Ray Satiro via curl-users <curl-users_at_cool.haxx.se>
Date: Wed, 27 Jan 2021 23:56:59 -0500

On 1/27/2021 9:13 PM, Hongyi Zhao via curl-users wrote:
> See my following testings about interacting with compressed remote
> resources using curl:
>
> werner_at_X10DAi:~$ curl --compressed -I --etag-save 111
> https://www.thepolyglotdeveloper.com/css/custom.min.css
> HTTP/2 200
> accept-ranges: bytes
> cache-control: public, max-age=0, must-revalidate
> content-type: text/css; charset=UTF-8
> date: Wed, 27 Jan 2021 15:05:06 GMT
> etag: "95b8df8e4f25366b91b9ed4850c8269e-ssl-df"
> strict-transport-security: max-age=31536000
> content-encoding: br
> age: 39361
> content-length: 1450
> server: Netlify
> vary: Accept-Encoding
> x-nf-request-id: 663ffd26-7b69-4c59-b0bb-50e6de8c7fa1-3429084
>
> werner_at_X10DAi:~$ cat 111
> 95b8df8e4f25366b91b9ed4850c8269e-ssl-df
>
> werner_at_X10DAi:~$ curl -I --etag-compare 111
> https://www.thepolyglotdeveloper.com/css/custom.min.css
> HTTP/2 200
> accept-ranges: bytes
> cache-control: public, max-age=0, must-revalidate
> content-length: 6285
> content-type: text/css; charset=UTF-8
> date: Thu, 28 Jan 2021 01:59:35 GMT
> etag: "95b8df8e4f25366b91b9ed4850c8269e-ssl"
> strict-transport-security: max-age=31536000
> age: 122
> server: Netlify
> x-nf-request-id: c731d3d2-19ee-4b03-91ec-b96e8d06464c-8953234
>
> werner_at_X10DAi:~$ curl -I --etag-compare 111 -H 'Accept-Encoding: gzip,
> deflate, br'https://www.thepolyglotdeveloper.com/css/custom.min.css
> HTTP/2 304
> date: Thu, 28 Jan 2021 02:02:00 GMT
> etag: "95b8df8e4f25366b91b9ed4850c8269e-ssl-df"
> cache-control: public, max-age=0, must-revalidate
> server: Netlify
> vary: Accept-Encoding
> x-nf-request-id: ae8bba17-c715-4a61-8e00-0a85d77334e2-5196200
>
>
> As you can see, I must supply appropriate 'Accept-Encoding:' string to
> the server combined with the saved etag for obtaining the correct
> response from the server, i.e., the 304 code for denoting that the
> remote resource hasn't been changed/updated since I've retrieved the
> etag last time.
>
> But I still can't figure out how to obtain the correct sting value for
> the 'Accept-Encoding:' used by the header for passing to the remote
> server. Any hints will be highly appreciated.


Accept-Encoding should not be manually set. Use --compressed which sets
it to the encodings supported by your build of curl.

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2021-01-28