Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
kako "uhvatit" http response - ak ce nekom trebat

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 29.04.2004 09:28    Post subject: kako "uhvatit" http response - ak ce nekom trebat Add user to your forum ignore list Reply with quote

eto, da ne ulazim u detalje - posljednji posao mi je zahtjevao rad sa httpom jer se sa nekog remote servera morao dohvatit fajl ili info o fajlu.
pa ako ce nekome trebati, evo kako dohvatit kolko je fajl velik i mime-type

Code:
<?php
$host = 'u4fps.gamer.hr';
$file = 'gogeta_anime_24_02_2004.zip';
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "HEAD /".$file." HTTP/1.1\r\n";
    $out .= "Host: ".$host."\r\n";
    $out .= "Connection: Close\r\n\r\n";

    fputs($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128)."<br />";
    }
    fclose($fp);
}
?>



response:

Code:
HTTP/1.1 200 OK
Date: Thu, 29 Apr 2004 08:24:08 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.0
Last-Modified: Sun, 18 Apr 2004 13:38:46 GMT
ETag: "1d418-28eb-408284e6"
Accept-Ranges: bytes
Content-Length: 10475
Connection: close
Content-Type: application/zip



zasto HEAD saljemo - head se salje ako se oce dobiti info o remote fajlu a ne zeli se potegnut cjeli fajl.
ako fajla nema:
Code:
HTTP/1.1 404 Not Found
Date: Thu, 29 Apr 2004 08:27:05 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.0
Connection: close
Content-Type: text/html; charset=iso-8859-1


fajl se nalazi i na http://u4fps.gamer.hr/check.php
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group