cURL / Mailing Lists / curl-library / Single Mail

curl-library

GET image after POST

From: Kam <kam.epi_at_gmail.com>
Date: Fri, 01 Aug 2008 10:05:42 -0400

I'm currently trying to write a program in C utilizing libcurl.

I'm using the Tamper Data and LiveHTTPheaders add-ons in firefox to see
the HTTP headers being traded between my computer and a server. There is
an initial GET to retrieve the cookies and PHPSESSID.

Next I POST with the desired form values which I retrieve from user
input. Right after this POST I need to GET an image/gif file. The img
src is located in the POST form and I don't know how to retrieve it and
issue a GET at that URL. Firefox does this sequence automatically but I
don't know how to program. Regexp and string searching is horrible in C
so I'm trying to avoid that.

Here's a breakdown of what I have so far:

Issue a GET @ URL: get cookies
Issue a POST: send needed form values
(Firefox issues a GET here at the URL within the next POST form, this is
what I need)
------------------------------------------------------------------------

This is what the POST form looks like:
<form method=post action="http://siteaddress.com/web_message"
name="challengeForm" onsubmit="return validate(this);">
<table style="margin-left: 75px;" border=1 cellpadding=0 cellspacing=0
height=55 width=300 bgcolor=#CCCCCC
background="http://siteaddress.com/images/background.gif"><tr>
<td><img height=55 width=300
src="http://siteaddress.com/unprot-bin/web_message.cgi?image=yes&fkey=~1217596520.8727.1422187.0&ServiceID=0119"></td>
</tr></table>
<p class=body style="margin-top:10px">
<table><tr valign=center><td valign=center class=body-bold>Enter Code
Above:</td>
<td valign=center><input autocomplete="off" type=text name=chresp></td>
<td valign=center><input type=image
value="Submit" src="http://siteaddress.com/images/submit_button.gif"><input
type=hidden name=fkey value="~1217596520.8727.1422187.0"><input
type=hidden name=ServiceID value="0119"></td>
</tr></table>
</p>
</form>

How does firefox automatically issue a GET for
http://siteaddress.com/unprot-bin/web_message.cgi?image=yes&fkey=~1217596520.8727.1422187.0&ServiceID=0119
?
I tried using CURLOPT_FOLLOWLOCATION with no success. I just need the
value of fkey from the above and then issue a GET at URL
http://siteaddress.com/unprot-bin/web_message.cgi?image=yes%fkey=[FKEY
VALUE]&ServiceID=0119

That's my logic so far.
Received on 2008-08-01