send_request ( $parse )

Sends the request, calling necessary utility functions to update built-in properties.

Access

public

Parameters

Parameter

Type

Required

Description

$parse

boolean

Optional

Whether to parse the response with ResponseCore or not.

Returns

Type

Description

string

The resulting unparsed data from the request.

Examples

Send the request, parse it with ResponseCore, and display only the body.

$http = new RequestCore('http://github.com/skyzyx/requestcore/raw/master/_tests/test_request.txt');
$response = $http->send_request(true);

var_dump($response->body);
Result:
string(48) "abcdefghijklmnopqrstuvwxyz
0123456789
!@#$%^&*()"

Set the URL via set_request_url() instead of the constructor, send the request, parse it with ResponseCore, and display only the body.

$http = new RequestCore();

$http->set_request_url('http://github.com/skyzyx/requestcore/raw/master/_tests/test_request.txt');
$response = $http->send_request(true);

var_dump($response->body);
Result:
string(48) "abcdefghijklmnopqrstuvwxyz
0123456789
!@#$%^&*()"

Send a HEAD request instead of a GET request, and display the response's Content-Type and non-body (since this is a HEAD request).

$http = new RequestCore('http://github.com/skyzyx/requestcore/raw/master/_tests/test_request.txt');
$http->set_method($http::HTTP_HEAD);
$response = $http->send_request(true);

var_dump($response->header['content-type']);
var_dump($response->body);
Result:
string(25) "text/plain; charset=utf-8"
bool(false)

Source

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback