0a144c6c5f5ae49786c2cb2b636a612843f6347c
[mdref/mdref-http] / http / Message / Body / __construct.md
1 # void http\Message\Body::__construct([resource $stream = NULL])
2
3 Create a new message body, optionally referencing $stream.
4
5 ## Params:
6
7 * Optional resource $stream = NULL
8 A stream to be used as message body.
9
10 ## Throws:
11
12 * http\Exception\InvalidArgumentException
13 * http\Exception\UnexpectedValueException
14
15 ## Example:
16
17 <?php
18 ob_end_clean();
19
20 $body = new http\Message\Body(fopen(__FILE__, "r"));
21 $resp = new http\Env\Response;
22 $resp->setContentType("text/plain");
23 $resp->setBody($body);
24 $resp->send();
25 ?>
26
27 Yields:
28
29 Accept-Ranges: bytes
30 X-Powered-By: PHP/5.5.5
31 Content-Type: text/plain
32 ETag: "138042e-527b5a0a-1b2"
33 Last-Modified: Thu, 07 Nov 2013 09:14:50 GMT
34
35 # void http\Message\Body::__construct([resource $stream = NULL])
36
37 Create a new message body, optionally referencing $stream.
38 ...