cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: curl HTTP PUT to a URL ending in "/"

From: Toby White <toby.o.h.white_at_googlemail.com>
Date: Fri, 16 Jan 2009 17:42:48 +0000

Firstly, it's not a filesystem sitting behind the HTTP server, it's a
set of HTTP-accessible web-services; but that's not really any of my
business as a client.

The URI is simply a reference to a resource, and the server is
promising to do various things according to what HTTP verb I send; if
I do a GET I'll get a representation of what's there, if I do a PUT
I'll overwrite that representation. Whether the URI ends in a forward
slash doesn't affect that.

I appreciate that the behaviour of -T makes perfect sense when writing
to a filesystem, or something pretending to be one, but in this case
it's not, I want to be able to do a PUT straight to the URI I specify.

The suggestion of URL-encoding doesn't work, and indeed shouldn't
under RFC 3986 - URIs differing only by percent-encoding of characters
reserved within that URI component (and / is a reserved character
within the path component) are not equivalent by section 2.2.

ie http://example.org/path%2F is a different URI from http://example.org/path/

Toby

On 16 Jan 2009, at 16:01, Doug McNutt wrote:

> At 15:32 +0000 1/16/09, Toby White wrote:
>> I want to PUT to the URL
>>
>> http://example.org/path/
>>
>> but curl won't seem to let me.
>>
>> If I do the obvious
>>
>> curl -T filename http://example.org/path/
>>
>> then curl actually tries to do the PUT on
>>
>> http://example.org/path/filename
>>
>> which is not what I want - I want the PUT request to go directly to
>> the URL I've asked for.
>
> To me, and to the ftp:// URLs I use all of the time, the trailing
> slash after "path" in your URL indicates that path is a directory.
>
> Actually I would think that the transmission should fail if a
> directory path does not exist. HTTP might default to creating the
> directory.
>
> And, at least in UNIX, a file name simply cannot end in a slash. Is
> the host a UNIX server? If not you might try some quotes or a URL
> encoded solidus.
> --
>
> --> From the U S of A, the only socialist country that refuses to
> admit it. <--
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
> FAQ: http://curl.haxx.se/docs/faq.html
> Etiquette: http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-01-16