#19 Remove default port for dodgy servers

open
nobody
None
5
2008-05-28
2008-05-28
Anonymous
No

Hi,

Snoopy can't download http://journal.neilgaiman.com/ because the server gives a 404 if the request headers include:

Host: journal.neilgaiman.com:80

You get a 200 with:

Host: journal.neilgaiman.com

This is the server's fault, but here's a hack anyway:

*** Snoopy.class.php.orig 2008-05-28 16:01:16.000000000 +0100
--- Snoopy.class.php 2008-05-28 16:02:24.000000000 +0100
***************
*** 795,801 ****
$headers .= "User-Agent: ".$this->agent."\r\n";
if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
$headers .= "Host: ".$this->host;
! if(!empty($this->port))
$headers .= ":".$this->port;
$headers .= "\r\n";
}
--- 795,801 ----
$headers .= "User-Agent: ".$this->agent."\r\n";
if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
$headers .= "Host: ".$this->host;
! if(!empty($this->port) && $this->port != 80)
$headers .= ":".$this->port;
$headers .= "\r\n";
}

Cheers,
Ian

Discussion

  • Nobody/Anonymous

    Logged In: NO

    Thank you, very useful trick!

     
  • Christian

    Christian - 2009-09-12

    Yes, I recently tracked strange errors down to this line as well. But remember to also not add the default port to HTTPS connections (port 443). I definetly think this should be in the next version of Snoopy.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks