Exemplo n.º 1
0
<?php

//require_once 'PEAR2/HTTP/Request/allfiles.php';
// to run from svn checkout
require_once '../../autoload.php';
$request = new PEAR2\HTTP\Request('http://pear.php.net/');
$request->verb = 'HEAD';
$response = $request->sendRequest();
var_dump($response->code);
var_dump($response->headers);
var_dump(strlen($response->body));
Exemplo n.º 2
0
<?php

$url = $testServer . 'test002.php';
$http = new PEAR2\HTTP\Request($url, $adapter);
$http->verb = 'POST';
$http->body = "Test\n";
$response = $http->sendRequest();
// make sure we got the correct body back
var_dump($response->body);
// check that the content-length header is correct
if (isset($response->headers['Content-Length'])) {
    var_dump($response->headers['Content-Length'] == 5);
}
/* Expects Should Be: 
string(5) "Test
"
bool(true)
*/
Exemplo n.º 3
0
/**
 * Do an HTTP request
 *
 * @param string $url_request
 *
 * @return string
 */
function inst_http_request($url_request, $returnCode = false)
{
    $result = null;
    $adapter = null;
    $response = null;
    $error = null;
    try {
        $bouncer = new \PEAR2\HTTP\Request($url_request);
        $result = $bouncer->sendRequest();
        $adapter = $bouncer->getAdapterName();
        $response = $result->body;
    } catch (\Exception $exception) {
        $error = $exception->getMessage();
    }
    x_install_log('inst_http_request() result', array('url_request' => $url_request, 'adapter' => $adapter, 'result' => $result, 'response' => $response, 'error' => $error));
    return $returnCode && $result ? $result->code : $response;
}