예제 #1
0
파일: HttpClient.php 프로젝트: echoOly/jomo
        while (!feof($this->fh)) {
            $this->response .= fread($this->fh, 1024);
        }
    }
    /**
     * 关闭socket连接
     * @access public
     */
    public function __destruct()
    {
        if ($this->fh) {
            fclose($this->fh);
        }
    }
}
$url = "http://localhost/jomo/http/test.php";
/** post test **/
$http2 = new HttpClient();
$header = array("Content-Type" => "application/x-www-form-urlencoded");
$body = array("username" => "1234", "submit" => "Login");
$http2->setUrl($url);
$http2->setHeader($header);
$http2->setBody($body);
var_dump($http2->post());
exit;
/** head test **/
$http3 = new HttpClient();
var_dump($http3->head($url, 1));
/** get test **/
$http1 = new HttpClient();
var_dump($http1->get($url));