big update's coming
[mdref/mdref-http] / http / Client / getHistory.md
1 # http\Message http\Client::getHistory()
2
3 Simply returns the http\Message chain representing the request/response history.
4
5 > **Note:** The history is only recorded while http\Client::$recordHistory is true.
6
7 ## Params:
8
9 None.
10
11 ## Returns:
12
13 * http\Message, the request/response message chain representing the client's history.
14
15 ## Throws:
16
17 * http\Exception\InvalidArgumentException
18
19 ## Example:
20
21 <?php
22 $client = new http\Client;
23 $client->enqueue(new http\Client\Request("HEAD", "http://php.net"));
24 $client->enqueue(new http\Client\Request("HEAD", "http://pecl.php.net"));
25 $client->enqueue(new http\Client\Request("HEAD", "http://pear.php.net"));
26 $client->recordHistory = true;
27 $client->send();
28
29 echo $client->getHistory()->toString(true);
30
31 Yields:
32
33 HEAD / HTTP/1.1
34 User-Agent: PECL::HTTP/2.0.0dev (PHP/5.5.5)
35 Host: pear.php.net
36 Accept: */*
37 Content-Length: 0
38
39 HTTP/1.1 200 OK
40 Date: Mon, 04 Nov 2013 15:41:48 GMT
41 Server: ...
42 X-Powered-By: PHP/5.3.6
43 Connection: close
44 Content-Type: text/html; charset=UTF-8
45 Content-Length: 0
46
47 HEAD / HTTP/1.1
48 User-Agent: PECL::HTTP/2.0.0dev (PHP/5.5.5)
49 Host: pecl.php.net
50 Accept: */*
51 Content-Length: 0
52
53 HTTP/1.1 200 OK
54 Date: Mon, 04 Nov 2013 14:34:02 GMT
55 Server: ...
56 X-Powered-By: PHP/5.2.17
57 Set-Cookie: ...
58 Expires: Thu, 19 Nov 1981 08:52:00 GMT
59 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
60 Pragma: no-cache
61 Connection: close
62 Content-Type: text/html; charset=ISO-8859-1
63 Content-Length: 0
64
65 HEAD / HTTP/1.1
66 User-Agent: PECL::HTTP/2.0.0dev (PHP/5.5.5)
67 Host: php.net
68 Accept: */*
69 Content-Length: 0
70
71 HTTP/1.1 200 OK
72 Server: ...
73 Date: Mon, 04 Nov 2013 14:34:08 GMT
74 Content-Type: text/html;charset=utf-8
75 Connection: keep-alive
76 X-Powered-By: PHP/5.5.4-1
77 Content-Language: en
78 Set-Cookie: ...
79 Last-Modified: Mon, 04 Nov 2013 21:00:36 GMT
80 Content-Length: 0