curl / Mailing Lists / curl-library / 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.

Unknown Content-Encoding value and zero-lenght string CURLOPT_ACCEPT_ENCODING

From: Fujii Hironori via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 28 Oct 2021 16:39:20 +0900

Hi,

Monaco Editor Samples is using their own HTTP server 'yaserver' which sends
an invalid 'Content-Encoding: utf8' header.
<https://github.com/microsoft/monaco-editor-samples>
<https://github.com/alexdima/yaserver>

If I invoke curl command, it reports no error for the unknown encoding.
> curl -v http://localhost:8888/

However, if I invoke curl commnad with '--compressed' switch, it reports
'CURLE_BAD_CONTENT_ENCODING' error.
~~~
$ curl -v --compressed http://localhost:8888/
* Trying 127.0.0.1:8888...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8888 (#0)
> GET / HTTP/1.1
> Host: localhost:8888
> User-Agent: curl/7.68.0
> Accept: */*
> Accept-Encoding: deflate, gzip, br
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Encoding: utf8
< Content-Type: text/html
< Expires: Thu, 28 Oct 2021 07:06:19 GMT
< ETag: e54e50d368dc1cf7edcfd55ca1226c7c
< Content-Length: 5736
< Date: Thu, 28 Oct 2021 07:06:14 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
* Unrecognized content encoding type. libcurl understands deflate, gzip, br
content encodings.
* Closing connection 0
curl: (61) Unrecognized content encoding type. libcurl understands deflate,
gzip, br content encodings.
~~~

According to <
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding>
'identity' value "is always considered as acceptable, even if omitted."
Why doesn't curl treat the unknown encoding as identity if
CURLOPT_ACCEPT_ENCODING is set to ""?
I want the zero-length string CURLOPT_ACCEPT_ENCODING to accept both
compressed and non-compressed encodings.

WebKit WinCairo port is using libcurl as the network stack, and it sets
CURLOPT_ACCEPT_ENCODING to "".
So, it can't load the content. However, Google Chrome and Firefox can load
the invalid encoding.

Should WinCairo set the CURLOPT_ACCEPT_ENCODING explicitly to the following
instead of "" ?

> curl_easy_setopt(m_handle, CURLOPT_ACCEPT_ENCODING, "identity, deflate,
gzip, br");

-- Fujii


-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2021-10-28