cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: httppost

From: Admir Efendic <admir_efendic_at_yahoo.com>
Date: Tue, 23 Oct 2001 04:06:13 -0700 (PDT)

I used curl C++ API:
-----------------------------------------------------

typedef struct
{
   char* xmlfile;
   char* jsessionid;
   size_t size;
} profile_t;

void* worker_thread(void* arg)
{
...
profile_t profile;
// log on and fill profile struct members
...

HttpPost* post = extract_logout_postfields(&profile);
curl_easy_setopt (h_curl, CURLOPT_MUTE, 1);
curl_easy_setopt (h_curl, CURLOPT_VERBOSE, 0);
curl_easy_setopt (h_curl, CURLOPT_STDERR, devnull);
curl_easy_setopt (h_curl, CURLOPT_WRITEFUNCTION,
WriteMemoryCallback);
curl_easy_setopt (h_curl, CURLOPT_FILE,(void*)&chunk);
curl_easy_setopt (h_curl, CURLOPT_COOKIEJAR,
cookie_filename);
curl_easy_setopt (h_curl, CURLOPT_HTTPPOST, post);
curl_easy_setopt (h_curl, CURLOPT_URL, url);
curl_easy_perform (h_curl);
curl_formfree(post);
}

HttpPost* extract_logout_postfields (profile_t*
profile)
{
   HttpPost* post = NULL;
   HttpPost* last = NULL;

   curl_formadd( &post, &last,
      CURLFORM_COPYNAME, "command",
      CURLFORM_COPYCONTENTS, "logout",
      CURLFORM_END );

   curl_formadd( &post, &last,
      CURLFORM_COPYNAME, "jsessionid",
      CURLFORM_PTRCONTENTS, profile->jsessionid,
      CURLFORM_END );

   curl_formadd( &post, &last,
      CURLFORM_COPYNAME, "profile",
      CURLFORM_PTRCONTENTS, profile->xmlfile,
      CURLFORM_END );

   return post;
}
-----------------------------------------------------

I'll try not to go in details in my code, but
basically, I have a ssl-webserver that sends an
xml-file (which contains some session data) when I log
on to the site.
In the same file I have an entity called jsessionid
which is basically an unsigned long.

To logout I have to send jessesionid and the xmlfile
itself using POST. I am trying to simulate an applet
which talks to a servlet via HTTPS (WebServices).

profile->xmlfile is url-encoded prior to setoptions (
with curl_escape ).

Ok, I know this is messy, but I hope it helps ;-)

/admir

 

--- Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Tue, 23 Oct 2001, Admir Efendic wrote:
>
> > Hi! I am trying to do a HTTPPOST on solaris 8, but
> snoop shows that I
> > have done GET instead:
>
> That is certainly weird. What options did you use?
>
> > Is there a way to see what EXACTLY has gone out to
> the web-server (at
> > byte level)?
>
> Yes, use 'curl -v' for verbose.
>
> --
> Daniel Stenberg -- curl groks URLs --
> http://curl.haxx.se/
>

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
Received on 2001-10-23