Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#13 Snoopy v1.2 status not set when fetching via https/curl

open
nobody
None
5
2005-10-06
2005-10-06
Tim
No

The status code is not getting set currectly in Snoopy
v1.2 when curl is used to handle https requests. Here
is a patch that fixes this problem using the same code
that is used in the non-https case:

$ diff -w -c20 -p Snoopy.class.php Snoopy.class.php.patched
*** Snoopy.class.php Thu Oct 6 13:21:28 2005
--- Snoopy.class.php.patched Thu Oct 6 13:21:10 2005
*************** class Snoopy
*** 1013,1053 ****
--- 1013,1059 ----
if(preg_match("/^(Location: |URI:
)/i",$result_headers[$currentHeader]))
{
// get URL portion of the redirect
preg_match("/^(Location:
|URI:)\s+(.*)/",chop($result_headers[$currentHeader]),$matches);
// look for :// in the Location
header to see if hostname is included
if(!preg_match("|\:\/\/|",$matches[2]))
{
// no host in the path, so prepend
$this->_redirectaddr =
$URI_PARTS["scheme"]."://".$this->host.":".$this->port;
// eliminate double slash
if(!preg_match("|^/|",$matches[2]))
$this->_redirectaddr .=
"/".$matches[2];
else
$this->_redirectaddr .=
$matches[2];
}
else
$this->_redirectaddr = $matches[2];
}

if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
+ {
+
if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$result_headers[$currentHeader],
$status))
+ {
+ $this->status= $status[1];
+ }
$this->response_code =
$result_headers[$currentHeader];
+ }

$this->headers[] =
$result_headers[$currentHeader];
}

// check if there is a a redirect meta tag

if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
{
$this->_redirectaddr =
$this->_expandlinks($match[1],$URI);
}

// have we hit our frame depth and is there
frame src to fetch?
if(($this->_framedepth < $this->maxframes) &&
preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\&gt;]+)'i",$results,$match))
{
$this->results[] = $results;
for($x=0; $x<count($match[1]); $x++)
$this->_frameurls[] =
$this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
}
// have we already fetched framed content?
elseif(is_array($this->results))

Discussion