reading Response Headers

This is a discussion on reading Response Headers within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi Group, I am working on web service where I am trying to execute a remote URL from within a ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-26-2005
ross
 
Posts: n/a
Default reading Response Headers

Hi Group,
I am working on web service where I am trying to execute a
remote URL from within a php file and would like to make some
decisions depending on the output.

I am using fopen to open the URL
$handle=@fopen("www.mysite.com/api/command","r");

If the command is successful it returns an XML file with
response headers. I have no problems reading the XML.

I am interested in the response header which has a session-ID.
how do I access this information.
any inputs are greatly appreciated..
Thanks a bunch,
Regards,
Ross

Reply With Quote
  #2 (permalink)  
Old 11-26-2005
Stefan Rybacki
 
Posts: n/a
Default Re: reading Response Headers

ross wrote:
> Hi Group,
>...
>


I guess a socket connection will help you.

http://de3.php.net/fsockopen

Regards
Stefan
Reply With Quote
  #3 (permalink)  
Old 11-26-2005
Iván Sánchez Ortega
 
Posts: n/a
Default Re: reading Response Headers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ross wrote:

> I am interested in the response header which has a session-ID.
> how do I access this information.


By using CURL functions to execute the HTTP query and grab the entire
results.

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_eat_s_p_a_m_for_breakfast@hotmail.com
Jabber:ivansanchez@jabber.org ; ivansanchez@kdetalk.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDiGKl3jcQ2mg3Pc8RAmUMAJ9LRLDlwL2UQJFWDgLUsT mU+B2vDQCeNiPi
7VRsczkuWWKJAQvEpyXL98s=
=g4+Q
-----END PGP SIGNATURE-----
Reply With Quote
  #4 (permalink)  
Old 11-26-2005
VS
 
Posts: n/a
Default Re: reading Response Headers

Stefan Rybacki wrote:
> ross wrote:
>
>> Hi Group,
>> ...
>>

>
>
> I guess a socket connection will help you.
>
> http://de3.php.net/fsockopen


Here's an exmaple I found and use to get the last modified time of a
remote file:

function filemtime_remote($uri)
{
$uri = parse_url($uri);
$uri['port'] = isset($uri['port']) ? $uri['port'] : 80;

// TimeOut
$tout = 5;
$handle = @fsockopen($uri['host'], $uri['port'], $errno, $errstr,
$tout);
if(!$handle)
return 0;

fputs($handle,"HEAD $uri[path] HTTP/1.1\r\nHost: $uri[host]\r\n\r\n");
$result = 0;
while(!feof($handle))
{
$line = fgets($handle,1024);
if(!trim($line))
break;

$col = strpos($line,':');
if($col !== false)
{
$header = trim(substr($line,0,$col));
$value = trim(substr($line,$col+1));
if(strtolower($header) == 'last-modified')
{
$result = strtotime($value);
break;
}
}
}
fclose($handle);
return $result;
}

$URL="http://www.xxxxx.com/filename.txt";
$tsrem = filemtime_remote($URL);

--
VS
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:05 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0