CocoaPods / cocoapods-downloader

A small library that provides downloaders for various source types (HTTP/SVN/Git/Mercurial)
MIT License
84 stars 71 forks source link

cURL version issue #105

Closed szuniverse closed 4 years ago

szuniverse commented 4 years ago

Hi guys!

The cocoapods-downloader 1.4 introduced this feature: https://github.com/CocoaPods/CocoaPods/issues/9619

macOS Catalina 10.15.6 is using the curl 7.64.1 by default and with the latest cocoapods-downloader-1.4.0 there is an issue. this cURL version is not able to handle this command:

curl -f -L -o /var/folders/file.zip https://example.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.9.3 cocoapods-downloader/1.4.0' output: curl: (6) Could not resolve host: cocoapods-downloader

somehow the latest 1.4 version is adding the -A 'CocoaPods/1.9.3 cocoapods-downloader/1.4.0' to the end of the command and the curl 7.64.1 is not able to handle this.

with curl 7.71.1 working perfectly but by default the macOS 10.15.6 is not using this version.

Do you plan to fix this issue in the next version?

dnkoutso commented 4 years ago

Not sure if cocoapods-downloader reads the version of curl but this is a valid issue/question. @amorde do you think we should check the curl version (or are we doing that already) and avoid adding the user agent part depending on version?

amorde commented 4 years ago

I would think there would be some way to specify this that works in both versions. Adding a user agent would be a pretty standard feature in curl correct?

Would need to dig into why this isn't working on that version

dnkoutso commented 4 years ago

@szuniverse can you check if curl 7.64.1 supports supplying a user agent? I agree with @amorde seems sounds like it should be supported

stidch commented 4 years ago

@dnkoutso Together with @szuniverse we found out that it's somehow only a problem if the string behind the -A contains spaces.

Leads to the error -A 'CocoaPods/1.9.3 cocoapods-downloader/1.4.0'

Passes -A 'CocoaPods/1.9.3' -A 'cocoapods-downloader/1.4.0'

amorde commented 4 years ago

Nice! I had a hunch that could be it.

Open to making a PR?

dnkoutso commented 4 years ago

From man curl

       -A, --user-agent <name>
              (HTTP) Specify the User-Agent string to send to the HTTP server. To encode blanks in the string, surround the string with
              single quote marks. This header can also be set with the -H, --header or the --proxy-header options.

              If this option is used several times, the last one will be used.

Is that a bug in curl then?

Just to be certain from the docs i dont think passing -A multiple times is the right approach.

dnkoutso commented 4 years ago

Btw the docs I pasted where from 7.64.1:

curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
dnkoutso commented 4 years ago

I also tried locally:

curl -f -L -o /var/folders/file.zip https://example.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.9.3 cocoapods-downloader/1.4.0'

That seems to work for me?

curl -f -L -o /var/folders/file.zip https://example.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.9.3 cocoapods-downloader/1.4.0'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Transient problem: timeout Will retry in 1 seconds. 2 retries left.
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Transient problem: timeout Will retry in 2 seconds. 1 retries left.
stidch commented 4 years ago

@dnkoutso You're probably right. We'll have to do some more tests with our local setup. It looks like a custom wrapper script could be the reason for the error here. We'll keep you updated!

szuniverse commented 4 years ago

Hi! The problem is in our custom CURL script. Our script is not able to handle the space in the -A argument. the problem is in our side..

amorde commented 4 years ago

Thanks!