babashka / babashka.curl

A This library is mostly replaced by https://github.com/babashka/http-client
Eclipse Public License 1.0
121 stars 9 forks source link

Bundled curl with Windows 10 doesn't support `--compressed` #36

Closed thiagokokada closed 3 years ago

thiagokokada commented 3 years ago

Using babashka v.0.4.1 on Windows, I tried to run the following in the REPL:

user=> (curl/get  "www.google.com")
clojure.lang.ExceptionInfo: curl: option --compressed: the installed libcurl version doesn't support this
curl: try 'curl --help' for more information
[at <repl>:1:1

Doing this instead it works:

user=> (curl/get "www.google.com" {:compressed false})
[Google webpage output]

We probably need to check for features. Using curl --version on Windows I got:

curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL Release-Date: 2017-11-14, security patched: 2019-11-05
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL 

On my NixOS system:

curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1k zlib/1.2.11 libssh2/1.9.0 nghttp2/1.41.0
Release-Date: 2020-12-09
Protocols: dict file ftp ftps gopher http https imap imaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets

According to this bug report, we need to check for either libz or brotli feature.

thiagokokada commented 3 years ago

BTW, I am using the following code to check for SSL feature in curl:

(defn- check-ssl-support!*
  []
  (as-> (shell/sh "curl" "--version") $
        (:out $)
        (re-seq #"(?m)^Features:.*(?:SSL).*" $)
        (assert $
                (str "You won't be able to use curl without SSL support!\n"
                     "Please install a curl version with SSL (for example, with \"brew install curl-openssl\")."))))

(defn check-ssl-support! (memoize check-ssl-support!*))
borkdude commented 3 years ago

After trying several checks, I decided to just go with some documentation. People can just upgrade their curl installation or use the :compress false option. I don't want to incur any overhead on the first request.

sejoharp commented 2 years ago

Https on windows 10 only works for me by adding :raw-args ["--ssl-no-revoke"] example:

(curl/get "https://google.com" {:compressed false :raw-args ["--ssl-no-revoke"]})

This is probably only necessary because I am not able to update curl. It always uses the default version although the powershell alias is already gone.

Without the parameter I get:

clojure.lang.ExceptionInfo: curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) 

update: Its due to antivirus/firewall. Curl works without --ssl-no-revoke, when I disable Kaspersky internet security or disable scanning encrypted connections.

Hopefully this helps someone else :-)

borkdude commented 2 years ago

@sejoharp Thanks for the report. Perhaps you can teach the virus-scanner to play well with curl. Babashka uses the curl which is on the PATH (see (System/getenv "PATH")), so you might be able to influence that.