티스토리 뷰

프로그래밍/PHP

php-소켓클래스(데모)

프링글 2008. 6. 22. 13:18

This demo (which may take a few seconds to load) attempts to retrieves the front page of Amazon.com and reports its size in bytes. Debug mode is switched on to show what the script is doing. This demonstrates the script automatically following redirections and maintaining cookies and referrers between sessions.

$client = new HttpClient('www.amazon.com');
$client->setDebug(true);
if (!$client->get('/')) {
    echo '<p>Request failed!</p>';
} else {
    echo '<p>Amazon home page is '.strlen($client->getContent()).' bytes.</p>';
}
HttpClient Debug: Request
GET / HTTP/1.0
Host: www.amazon.com
User-Agent: Incutio HttpClient v0.9
Accept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*
Accept-encoding: gzip
Accept-language: en-us

HttpClient Debug: HTTP/1.1 200 OK
HttpClient Debug: Received Headers
Array
(
    [date] => Sat, 07 Jul 2007 08:11:56 GMT
    [server] => Server
    [set-cookie] => Array
        (
            [0] => skin=noskin; path=/; domain=.amazon.com; expires=Sat, 07-Jul-2007 08:11:56 GMT
            [1] => session-id-time=1184396400l; path=/; domain=.amazon.com; expires=Sat Jul 14 07:00:00 2007 GMT
            [2] => session-id=105-5067105-8918840; path=/; domain=.amazon.com; expires=Sat Jul 14 07:00:00 2007 GMT
        )

    [x-amz-id-1] => 1TSSY3EKCBSR9Y20Q4B1
    [x-amz-id-2] => XKVQLyygL+30648rPVdvGVUnDw6NrcKT
    [vary] => Accept-Encoding,User-Agent
    [content-encoding] => gzip
    [content-type] => text/html; charset=ISO-8859-1
    [connection] => close
)
HttpClient Debug: Content is gzip encoded, unzipping it
HttpClient Debug: Persisting referer: http://www.amazon.com/

Amazon home page is 130681 bytes

'프로그래밍 > PHP' 카테고리의 다른 글

php-소켓클래스(소스)  (0) 2008.06.22
php-소켓클래스(Example)  (0) 2008.06.22
php 소켓 클래스(설명)  (0) 2008.06.22
2003년 6월식 php 바코드 생성 함수  (0) 2008.06.22
금액(문자) -> 숫자로 변환 함수  (0) 2008.06.22
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크