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

  • Hi people,

    I'm trying to do something that is actually quite simple on the PC,
    but for the Mac I'm finding this hard. So this is a bit of a shame
    really.

    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!

    It's done on the PC using this library called W3Client which was
    found on codeproject.com:

      W3Client w3;

      w3.Connect("http://gdst2.simslearning.co.uk/learnwise", username,
    password); // logs in here

      w3.AddPostArgument("course", strFile, TRUE);

      w3.Request("/coursebuilder/importCourse/org/dep",
    W3Client::reqPostMultipartsFormdata); // uploads!

    See, easy!

    w3.Request will connect to the URL "http://gdst2.simslearning.co.uk/
    learnwise/coursebuilder/importCourse/org/dep"

    So basically, it appends the thing to the URL it connected to.

    The uploading is done via the Post argument thingy.

    So, I can do this with 4 lines of code on the PC using W3Client.

    I tried with curl, which eventually I found couldn't work, simply
    because... I can't log into one url and then upload to another.
    Believe me I tried all sorts of different combinations with curl. I
    tried multiple connection attempts (calling curl then calling it
    again after it completes). I tried passing two urls to curl, that
    also failed because the login page refuses to login if I've got any
    POST arguments!

    It just won't work.

    I don't see the ability to post arguments using Cocoa? And also the
    API is really hard to use. It's delegate madness and class madness. I
    must use about 4 classes and a delegate to do something I could do
    with 4 lines of code with W3Client. W3Client is written for the Win32
    API however. And even then I haven't seen http post with
    NSURLConnection, and I haven't seen the ability to log into a
    different page than you upload to.

    So how can I upload using http post to a different url than the one I
    logged in, to acheive what I did with the above 4 lines of W3Client
    code?

    Can Macs even do this?

    Must I resort to writing my own socket wrapper and do all the http
    stuff manually? :(

    --
    http://elfdata.com/plugin/
  • >
    > Must I resort to writing my own socket wrapper and do all the http
    > stuff manually? :(

    To be clear I don't mind how it's done. Cocoa, curl, libcurl, Carbon,
    bsd, manually, whatever.

    I just want the simplest way that works. I'm assuming manually is
    going to be tedious, so hopefully there's a simpler way.
previous month november 2006 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Go to today