[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: wget vs curl (was ... Re: debian 8)



David Wright wrote:
> Reco wrote:
> > So, in the case of doubt - you use curl or rebuild wget against
> > openssl. It's that simple.

I know that people have strong feelings for and against curl and wget.
I haven't ever understood it.  You are the first to quantify why you
think Debian's curl deals better with https sites.  It appears the
issues all surround https handling.

It also appears that when multiple trust paths exist that wget checks
all trust paths and all must verify or it complains.  Normally
browsers only check if any trust path exists.  An AND versus OR
relationship difference.  So that is another ding against wget for
https handling.

However for non-https sites I think wget is more user friendly.  I
almost always use wget over curl for this reason.

> So I typed curl in place of wget and...
>
> jessie $ curl http://cdimage.debian.org/cdimage/jessie_di_rc2/i386/iso-cd/debian-jessie-DI-rc2-i386-netinst.iso

Caution.  'curl' outputs to stdout.  There is no redirection in the
above.  If it had worked then it would have spewed the binary iso at
your terminal.  With curl you need to redirect the output to a file
whereas wget does that by default.

> ...302 Found...
> <p>The document has moved <a href="http://gensho.acc.umu.se/cdimage/jessie_di_rc2/i386/iso-cd/debian-jessie-DI-rc2-i386-netinst.iso";>here</a>.</p>
> <hr>

By default curl does not follow standard http redirections.  Must add
the -L option.

> OK, let's try wget...
>
> jessie $ wget http://cdimage.debian.org/cdimage/jessie_di_rc2/i386/iso-cd/debian-jessie-DI-rc2-i386-netinst.iso
>...
> Location: http://gensho.acc.umu.se/cdimage/jessie_di_rc2/i386/iso-cd/debian-jessie-DI-rc2-i386-netinst.iso
> [following]

By default wget observes the standard http redirection and follows
it.  By default wget saves the file with the appropriate file name.

> So I guess I need an option. man curl
> Hmm, over 2000 lines. Tomorrow maybe...

Let me help narrow things down.  It is the -L option.

  man curl

       -L, --location
              (HTTP/HTTPS) If the server reports that the requested  page  has
              moved to a different location (indicated with a Location: header
              and a 3XX response code), this option will make  curl  redo  the
              request on the new place. If used together with -i, --include or
              -I, --head, headers from all requested pages will be shown. When
              authentication  is  used, curl only sends its credentials to the
              initial host. If a redirect takes curl to a different  host,  it
              won't  be  able to intercept the user+password. See also --loca-
              tion-trusted on how to change this. You can limit the amount  of
              redirects to follow by using the --max-redirs option.

              When  curl follows a redirect and the request is not a plain GET
              (for example POST or PUT), it will do the following request with
              a GET if the HTTP response was 301, 302, or 303. If the response
              code was any other 3xx code, curl  will  re-send  the  following
              request using the same unmodified method.

              You  can  tell  curl to not change the non-GET request method to
              GET after a 30x response by  using  the  dedicated  options  for
              that: --post301, --post302 and -post303.

Something like either of these:

  $ curl -L -o debian-jessie-DI-rc2-i386-netinst.iso http://cdimage.debian.org/cdimage/jessie_di_rc2/i386/iso-cd/debian-jessie-DI-rc2-i386-netinst.iso

  $ curl -L http://cdimage.debian.org/cdimage/jessie_di_rc2/i386/iso-cd/debian-jessie-DI-rc2-i386-netinst.iso > debian-jessie-DI-rc2-i386-netinst.iso 

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: