Headers and a bit of PHP code

jjshell Messages postés 2 Date d'inscription jeudi 3 mars 2005 Statut Membre Dernière intervention 7 mars 2005 - 6 mars 2005 à 14:51
jjshell Messages postés 2 Date d'inscription jeudi 3 mars 2005 Statut Membre Dernière intervention 7 mars 2005 - 7 mars 2005 à 10:00
hi there :)


here are the header I get for a given page of one of my app.


I'm struggling to make two apps communicate.


I'm having a hard time, belive me. For some reasons, it's hard to get help with http headers.


Anyway, here are the header (I replaced a few info for privacy reasons):


[url]https://www.host.com/some/stuff/url


GET /some/stuff HTTP/1.1
Host: [url]www.host.com/url
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: [url]https://www.host.com/folder/login/url
Cookie: PHPSESSID=AGDzf340cZXI13itJULFlaFrWloby7my1UvdpcCQH6rCLTwg8RrB!1730171794; ades.lb=EDA82001; user.session=999IuB8325A548F5E3A1CCDA2874FC




I'd like to connect to this page with the following script:


[php]
$host = 'www.host.com';
$port = '80';
$timeout = '10';
$uri = '/some/stuff';


if (!$fp = fsockopen($host,$port,$errNo,$errMsg,$timeout))
{
die($errNo . $errMessage);
}





fputs($fp, "GET " . $uri . " HTTP/1.1\r\n");
fputs($fp, "HOST: " . $host . "\r\n");
fputs($fp, "Referer: https://www.host.com/folder/login\r\n");
fputs($fp, "Cookie: PHPSESSID=" . $_SESSION['PHPSESSID'] . "; ades.lb=" . $_SESSION['adeslb'] . "; user.session=" . $_SESSION['usersession'] . "\r\n");



while (!feof($fp)) {
$chunk = fgets($fp);
echo($chunk);
}


fclose($fp);
/php


As you can see, I stored in session variables all the data necessary for the Cookie header (I got all that from a previous page).


My script times out. It just doesn't work. Would anyone shed some lights on this subject? What do I have to do to act as a logged in user?


Just one thing: I can login, that's fine. After the login script, I shoud be redirected to the page I am trying to reach but my script doesn't handle the redirect, I must therefore call the page myself (as shown above). Should I simulate a redirect? If yes, how?


Here are the relevant headers:


HTTP/1.x 302 Moved Temporarily
Date: Sun, 06 Mar 2005 13:27:21 GMT
Server: Apache
Location: [url]https://www.host.com/some/stuff/url
ades-filters-lb-address: EDA82001
Transfer-Encoding: chunked
Content-Type: text/plain; charset=ISO-8859-1
Via: 1.1 217.59.157.112 (Alteon iSD-SSL/5.4.3.8)

1 réponse

jjshell Messages postés 2 Date d'inscription jeudi 3 mars 2005 Statut Membre Dernière intervention 7 mars 2005
7 mars 2005 à 10:00
au fait, toutes mes excuses si le message est posté en anglais :)
0
Rejoignez-nous