cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Uploading file to auth http server, when login url is different to upload url??

From: Theodore H. Smith <delete_at_elfdata.com>
Date: Wed, 1 Nov 2006 18:44:50 +0000

On 1 Nov 2006, at 18:25, Dan Fandrich wrote:

> On Wed, Nov 01, 2006 at 05:32:21PM +0000, Theodore H. Smith wrote:
>> I want to log into into a certain url with http auth by supplying a
>> name and password, and without breaking the http connection, then
>> upload a file to a different url!
>
> "without breaking the http connection" implies that HTTP is a stateful
> protocol, which it is not. This means that the server shouldn't care
> if you perform two requests on a single TCP connection or two.

That should help tremendously! Thanks for point that out, even though
I should have known ;)

> If you
> have a case where you need to "log in" to one URL, then perform an
> operation on another URL, usually the state is held in cookies. Have
> you tried to skip the "log in" URL and simply do the upload on the
> second URL, but providing the proper authentication IDs? That should
> work unless cookies are being used.

Yes I tried. I got a 404 error. I can't actually tell if it's simply
ignoring me (as it should), or the file to upload really doesn't exist.

>> I tried with curl (as a shell tool not library), which eventually I
>> found couldn't work, simply because... I can't log into one url and
>> then upload to another. I tried all sorts of different combinations
>
> Sure you can. If the state is stored in cookies, then just give two
> curl commands, the first login one with the -c option, the second
> upload
> one with the -b option.

I tried -c "cookiesTest.txt"

I got a "login accepted" page returned. Only thing... no
cookiesText.txt was created. I assume that means the server is
returning no cookies? I wonder how it knows if we are logged in or
not then?

>> Can Macs even do this?
>
> It's not a Mac-specific issue.

I was just teasing. What I really meant was "does the Mac even have
suitable handy APIs as good as the W3Client". I know network stuff is
platform neutral by nature. After seeing how easy the PC guy has it
working on this, I'm kinda jealous I'm finding it so hard :(

>> Must I resort to writing my own socket wrapper and do all the http
>> stuff manually? :( If it can't be done with curl, perhaps some Mac
>> people can tell me the easiest way to do this? As it looks to me,
>> Cocoa can't do it.
>
> It probably can, once you figure out what's involved in "logging in".

OK good to hear. Will curl as a shell tool be enough or must I use
the library? If possible, I'd rather use it in shell form, simply
because my code is already set up this way and it's easier to
experiment with in the OSX terminal.
Received on 2006-11-01