42 $r->setBody(
fopen(
'php://input',
'r'));
61 foreach ($value as $k => $v) {
63 header($key .
': ' . $v);
65 header($key .
': ' . $v,
false);
72 if (is_null($body))
return;
77 if (is_resource($body) && get_resource_type($body) ==
'stream') {
78 if (PHP_INT_SIZE !== 4){
83 while (!feof($body)) {
84 fwrite(
$output, fread($body, 8192));
91 file_put_contents(
'php://output', $body);
94 if (is_resource($body)) {
112 $httpVersion =
'1.1';
115 $hostName =
'localhost';
117 foreach ($serverArray as
$key => $value) {
121 case 'SERVER_PROTOCOL' :
122 if ($value ===
'HTTP/1.0') {
123 $httpVersion =
'1.0';
126 case 'REQUEST_METHOD' :
134 case 'CONTENT_TYPE' :
135 $headers[
'Content-Type'] = $value;
137 case 'CONTENT_LENGTH' :
138 $headers[
'Content-Length'] = $value;
143 case 'PHP_AUTH_USER' :
144 if (isset($serverArray[
'PHP_AUTH_PW'])) {
145 $headers[
'Authorization'] =
'Basic ' . base64_encode($value .
':' . $serverArray[
'PHP_AUTH_PW']);
150 case 'PHP_AUTH_DIGEST' :
151 $headers[
'Authorization'] =
'Digest ' . $value;
156 case 'REDIRECT_HTTP_AUTHORIZATION' :
157 $headers[
'Authorization'] = $value;
162 $headers[
'Host'] = $value;
166 if (!empty($value) && $value !==
'off') {
172 if (substr(
$key, 0, 5) ===
'HTTP_') {
195 $r->setHttpVersion($httpVersion);
196 $r->setRawServerData($serverArray);
This interface represents a HTTP response.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
The Request class represents a single HTTP request.
static getRequest()
This static method will create a new Request object, based on the current PHP request.
if(preg_match('#\.( $contentLength[^/\.]+)$#D', $path, $type)) if($contentType===null)
getHeaders()
Returns all the HTTP headers as an array.
getHeader($name)
Returns a specific HTTP header, based on it's name.
static sendResponse(ResponseInterface $response)
Sends the HTTP response back to a HTTP client.
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
getHttpVersion()
Returns the HTTP version.
getStatus()
Returns the current HTTP status code.
getBody()
Returns the message body, as it's internal representation.
getStatusText()
Returns the human-readable status string.