cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Fwd: Bug#311112: curl: Escape <space> in HTTP requests

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 29 May 2005 20:22:13 +0200 (CEST)

On Sat, 28 May 2005, Domenico Andreoli wrote:

(This is a reply to the libcurl list that this was sent to, but the report (or
wish actually) regards curl the command line tool. Therefore, this is also
sent to the curl-users list where follow-ups should be taken, if any.)

> For example mp3 files often contain space characters in their
> filename, however curl will not deal with that:

This is very much on purpose.

First, curl operates and URLs and spaces are not part of legal URLs.

curl is as liberal as possible to what URLs it accepts and lets through (as
long as it can extract the host name etc). It allows users to send lots of
weird things through to servers.

Having curl translate illegal letters into something else would take a lot of
effort and "intelligence" in the tool I much rather avoid. Is translation to
%20 *always* wanted when you pass a space in the URL? I doubt that.

Also (of course) different servers and different protocols will treat that
literal space differently.

> Of course *I* could do the escaping and invoke curl
> 'http://downhill.aus.cc/testingcurl/with%20space'

That is what you are expected to do. If you want a %20 sent to a HTTP server.

> however in that case I'll end up with a file named "with%20space" locally if
> I use -O and will need to do manual de-escaping with mmv, too.

Yes, but if you don't like what -O gives you, why not use -o and intent your
own file name?

-- 
          -=- Daniel Stenberg -=- http://daniel.haxx.se -=-
   ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol
Received on 2005-05-29