Pages: [1]
wizzszz
BAM!ID: 86
Joined: 2006-05-10
Posts: 205
Credits: 34,259
World-rank: 1,064,374

2006-06-16 10:13:13

Hello Willy,

yesterday i posted a message in a forum w/ an external picture link for the first time. It works fine, but now i have some strange behaviour in my http-servers log:

the boincstat server seems to try to validate the picture link by sending a HEAD request...
AND the link was modified, too, a trailing '.' was included in the URI

the trailing '.' doesn't make a problem to my server, it send the document properly... (but it may be a problem for other servers...)

But the validation HEAD request doesn't follow the RFC 2616 rules:
The request URI contains the FQDN, like sent to a proxy server (including the http:// and the host name)
My server responds with a 404 not found, and the boinc deamon is retrying the request every time the page is accessed!

There is no Referer or Agent token given, so i assume you wrote this validator client yourself...
According to RFC 2616, the request to a server MUST NOT contain the protocol prefix/the Host name.

Drop me a line, if you need assistance, or, as i suggested some month ago, let me try to help you in my spare time...
(Well, BOINCstats is great, and i want to support it with some of my spare time)
[BOINCstats] Willy
 
Forum moderator - Administrator - Developer - Tester - Translator
BAM!ID: 1
Joined: 2006-01-09
Posts: 9456
Credits: 353,172,950
World-rank: 4,971

2006-06-16 10:22:35
last modified: 2006-06-16 10:25:26

Before showing an image in the forum, the code:

1: checks if the image actually exists (to prevent an error on 2)
2: checks the size of the image
3: if the image is to large add height and width to the images to fit it in the forum, and maintain proportions

1 is code I found as freeware on the internet, and it sends a head request. the php code (with the head part) is:

Code:

function remote_file_exists ($url)
{
/*
Return error codes:
1 = Invalid URL host
2 = Unable to connect to remote host
*/
$head = "";
$url_p = parse_url ($url);

if (isset ($url_p["host"]))
{ $host = $url_p["host"]; }
else
{ return 1; }

if (isset ($url_p["path"]))
{ $path = $url_p["path"]; }
else
{ $path = ""; }

$fp = fsockopen ($host, 80, $errno, $errstr, 20);
if (!$fp)
{ return 2; }
else
{
$parse = parse_url($url);
$host = $parse['host'];

fputs($fp, "HEAD ".$url." HTTP/1.1\r\n&quot ;
fputs($fp, "HOST: ".$host."\r\n"
fputs($fp, "Connection: close\r\n\r\n&quot ;
$headers = "";
while (!feof ($fp))
{ $headers .= fgets ($fp, 128); }
}
fclose ($fp);
$arr_headers = explode("\n", $headers) ;
$return = false;
if (isset ($arr_headers[0]))
{ $return = strpos ($arr_headers[0], "404&quot === false; }
return $return;
}


Let me know how I can improve this code. Thanks in advance.


Edit: hmmm, immediately found another bug: there should be no smileys in code.
Please do not PM, IM or email me for support (they will go unread/ignored). Use the forum for support.
wizzszz
BAM!ID: 86
Joined: 2006-05-10
Posts: 205
Credits: 34,259
World-rank: 1,064,374

2006-06-16 11:01:42

Hello Willy,

thanks for the fast reply!

I am not very into php, but the line

fputs($fp, "HEAD ".$url." HTTP/1.1\r\n" ;

got to be replaced with

fputs($fp, "HEAD ".$url_p["path"]." HTTP/1.1\r\n" ;

As i understand it, $url is the full path before parsing,
and you should use $url_p["path"],
which is only the ressource path.

Did you get valid results from any other servers?
Should work anyway with apache servers, because they support proxy mode...

But i still have no clue where the trailing '.' comes from...

My server is online during development phase from 12:00-02:00 UTC
(14:00-04:00 german summer time)

Could trace the Request if you tell me when you want to test the improvements...

my ICQ# should be in my user profile (41-565-332)

i am in stealth mode, so you won't see me as 'online', just give it a try...

BTW: did you read my reply on the cacheing thread?
wizzszz
BAM!ID: 86
Joined: 2006-05-10
Posts: 205
Credits: 34,259
World-rank: 1,064,374

2006-06-16 11:06:41

well, forgot to include the closing ')' in the code lines!

(If you just want to copy&paste it)

Thats why I have no smileys

And forgot to ask: DO you have icq?
Pages: [1]

Index :: BAM! Bug Report :: external pics in forum threads
Reason: