PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Joshua Gilman   HTTPSock   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: File testing the class
Class: HTTPSock
Send HTTP requests to a Web server using sockets
Author: By
Last change:
Date: 17 years ago
Size: 606 bytes
 

Contents

Class file image Download
<?php

require_once('HTTPsock.class.php');

$socket = new HTTPSock();

/* Simple GET */
echo $socket->HTTPRequest("GET", "http://www.google.com/");

/* Advanced POST, use array's for overwriting header values and using POST variables */
$header = array("Referer" => "http://www.google.com");
echo
$socket->HTTPRequest("POST", "www.google.com/someform.phtml", array("somevar" => "somevalue"), $header);

/* Returns the a cookie with the name 'somecookie' */
echo $socket->cookies['somecookie'];

/* Returns what the content was encoded in */
echo $socket->headers['Content-Encoding'];

?>