cURL / Mailing Lists / curl-library / Single Mail

curl-library

cookie sending in url

From: bart vanherck <bart.vanherck_at_linux.be>
Date: 05 May 2003 20:15:26 +0200

Hello,

I try to do program the following commands in a c-program with libcurl

curl --proxy proxy.pandora.be:8080 -o one.html -L -D ./cookie2
-d"uid=xxx&pwd=yyyy&goto=http:%2F%2F:www.telenet.be"
https://www.telenet.be/sys/sso/exec_login.php

Now there are stored 2 session cookies one of them is $SSOSID which is
returned in the next url I want to access.

curl --proxy proxy.pandora.be:8080 -o two.html -L -b ./cookie2
"https://www.telenet.be/sys/sso/jump.php?https://services.telenet.be/isps/MainServlet?ACTION=TELEMTR&SSOSID=f832a44aab631ba51acfe714a05faad7ae4e8d445536cf12"

My problem is how I can do this in libcurl. Is there a way to get a
cookie ? because if I use the following code :

#define MYURL "https://www.telenet.be/sys/sso/exec_login.php"

    sprintf(data,"uid=%s&pwd=%s&goto=%s",UID,PWD,GOTO);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 0);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_easy_setopt(curl, CURLOPT_HEADER, 1);
    curl_easy_setopt(curl, CURLOPT_PROXY, "proxy.pandora.be:8080");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/telemeter.cookie");
    curl_easy_setopt(curl, CURLOPT_URL, MYURL);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);

    res=curl_easy_perform(curl);

with the callback function
size_t write_function(void *buffer, size_t size, size_t nmemb, void
*userp)
{
        printf("------------------------------------\n");
        printf("%s\n",(char *)buffer);
        printf("------------------------------------\n");
}

The buffer has only the following code in it HTTP/1.1 302 Found

If I comment out the callback function
//curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);

I get an output :

* About to connect() to proxy.pandora.be:8080
* Connected to nchobo03.telenet-ops.be (213.224.83.150) port 8080
* Establish HTTP proxy tunnel to www.telenet.be:443
* Proxy replied to CONNECT request
* SSL connection using EDH-RSA-DES-CBC3-SHA
* Server certificate:
* subject: /C=BE/L=Mechelen/O=Telenet Operaties
NV/CN=www.telenet.be
* start date: 2003-03-27 08:50:38 GMT
* expire date: 2004-03-27 08:50:38 GMT
* issuer: /C=BE/O=GlobalSign nv-sa/OU=Secure Server
CA/CN=GlobalSign Secure Server CA
> POST /sys/sso/exec_login.php HTTP/1.1
Host: www.telenet.be
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Length: 55
Content-Type: application/x-www-form-urlencoded
uid=xxxx&pwd=yyyy&goto=http:%2F%2Fwww.telenet.beHTTP/1.1 302 Found
Date: Mon, 05 May 2003 18:09:55 GMT
Server: Apache
Expires: Thu, 1 Jan 1970 01:00:00 +0100
Cache-Control: no-cache; must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: TNSESSID=e7177355100f6d6d146867e5b93611de; path=/
Set-Cookie: SSOSID=064996f216d946a53f79eff6a210c2580ac64695c657ce36;
path=/; secure
Location: https2http.php?http://www.telenet.be
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1

* Follow to new URL: https2http.php?http://www.telenet.be
* Closing connection #0
* Follows Location: to new URL:
'https://www.telenet.be/sys/sso/https2http.php?http://www.telenet.be'
* Disables POST, goes with GET
* About to connect() to proxy.pandora.be:8080
* Connected to nchobo03.telenet-ops.be (213.224.83.150) port 8080
* Establish HTTP proxy tunnel to www.telenet.be:443
* Proxy replied to CONNECT request
* SSL re-using session ID
* SSL connection using EDH-RSA-DES-CBC3-SHA
* Server certificate:
* subject: /C=BE/L=Mechelen/O=Telenet Operaties
NV/CN=www.telenet.be
* start date: 2003-03-27 08:50:59 GMT
* expire date: 2004-03-27 08:50:59 GMT
* issuer: /C=BE/O=GlobalSign nv-sa/OU=Secure Server
CA/CN=GlobalSign Secure Server CA
> GET /sys/sso/https2http.php?http://www.telenet.be HTTP/1.1
Host: www.telenet.be
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Cookie: SSOSID=064996f216d946a53f79eff6a210c2580ac64695c657ce36;
TNSESSID=e7177355100f6d6d146867e5b93611de

HTTP/1.1 200 OK
Date: Mon, 05 May 2003 18:09:58 GMT
Server: Apache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" />
<html>
    <head>
        <meta http-equiv="Refresh" content="0;
URL=http://www.telenet.be" />
    </head>
    <body></body>
</html>
* Closing connection #0

Kind regards,
Bart

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-05-05