diff options
| author | bptato <nincsnevem662@gmail.com> | 2023-11-17 23:07:10 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2023-11-17 23:17:39 +0100 |
| commit | 85c5b568510e3be46252a0857e412ef0f66eb6de (patch) | |
| tree | 6c221532931f42d129ac7ec0ac8da8a00a92b59c | |
| parent | d454eab33b645e108a8a2dae84bdbcece6f7e877 (diff) | |
| download | chawan-85c5b568510e3be46252a0857e412ef0f66eb6de.tar.gz | |
http: use Accept-Encoding
just ask libcurl to decode
| -rw-r--r-- | res/config.toml | 1 | ||||
| -rw-r--r-- | src/bindings/curl.nim | 1 | ||||
| -rw-r--r-- | src/loader/http.nim | 3 |
3 files changed, 5 insertions, 0 deletions
diff --git a/res/config.toml b/res/config.toml index dcf98951..f821d694 100644 --- a/res/config.toml +++ b/res/config.toml @@ -40,6 +40,7 @@ prepend-https = true default-headers = { User-Agent = "chawan", Accept = "text/html,text/*;q=0.5", + Accept-Encoding = "gzip, deflate", Accept-Language = "en;q=1.0", Pragma = "no-cache", Cache-Control = "no-cache" diff --git a/src/bindings/curl.nim b/src/bindings/curl.nim index 46553539..cd9e409a 100644 --- a/src/bindings/curl.nim +++ b/src/bindings/curl.nim @@ -93,6 +93,7 @@ type CURLOPT_POSTFIELDS = CURLOPTTYPE_OBJECTPOINT + 15 CURLOPT_HTTPHEADER = CURLOPTTYPE_SLISTPOINT + 23 CURLOPT_HEADERDATA = CURLOPTTYPE_CBPOINT + 29 + CURLOPT_ACCEPT_ENCODING = CURLOPTTYPE_STRINGPOINT + 102 CURLOPT_MIMEPOST = CURLOPTTYPE_OBJECTPOINT + 269 # Functionpoint diff --git a/src/loader/http.nim b/src/loader/http.nim index f56341f4..d7bc3a8f 100644 --- a/src/loader/http.nim +++ b/src/loader/http.nim @@ -112,6 +112,9 @@ proc loadHttp*(handle: LoaderHandle, curlm: CURLM, curl.setopt(CURLOPT_WRITEFUNCTION, curlWriteBody) curl.setopt(CURLOPT_HEADERDATA, handleData) curl.setopt(CURLOPT_HEADERFUNCTION, curlWriteHeader) + if "Accept-Encoding" in request.headers: + let s = request.headers["Accept-Encoding"] + curl.setopt(CURLOPT_ACCEPT_ENCODING, cstring(s)) if request.proxy != nil: let purl = request.proxy.serialize() curl.setopt(CURLOPT_PROXY, purl) |