PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Tobias Marstaller   PHP Simple HTTP Request   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Simple Proxy-Code as an example
Class: PHP Simple HTTP Request
Send HTTP 1.1 requests via TCP socket connections
Author: By
Last change:
Date: 10 years ago
Size: 657 bytes
 

Contents

Class file image Download
$request = new HttpRequest("www.google.com");
if ($request->browseTo("/"))
{
    $info = $request->getRequestInfo();
    if ($info["statuscode"] == 404)
    {
        exit("<h1>404 - Not Found</h1>");
    }
    $header = $request->getRequestHeader();
    if (isset($header["Content-type"]))
    {
        header("Content-type: " . $header["Content-type"]);
    }
    if (isset($header["Content-length"]))
    {
        header("Content-length: " . $header["Content-length"]);
    }
    if (isset($header["Content-disposition"]))
    {
        header("Content-disposition: " . $header["Content-disposition"]);
    }
    echo $request->getOutput();
}
else
{
    exit("<h1>Could not reach www.google.de");
}