55beb658a6d5eb35ec8c8337a96f4221d60d4871
[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 ## Example:
16
17 <?php
18 $client = new http\Client;
19 $client->enqueue(new http\Client\Request("HEAD", "http://php.net"));
20 $client->enqueue(new http\Client\Request("HEAD", "http://pecl.php.net"));
21 $client->enqueue(new http\Client\Request("HEAD", "http://pear.php.net"));
22 $client->recordHistory = true;
23 $client->send();
24
25 echo $client->getHistory()->toString(true);
26
27 Yields:
28
29 HEAD / HTTP/1.1
30 User-Agent: PECL::HTTP/2.0.0dev (PHP/5.5.5)
31 Host: pear.php.net
32 Accept: */*
33 Content-Length: 0
34
35 HTTP/1.1 200 OK
36 Date: Mon, 04 Nov 2013 15:41:48 GMT
37 Server: ...
38 X-Powered-By: PHP/5.3.6
39 Connection: close
40 Content-Type: text/html; charset=UTF-8
41 Content-Length: 0
42
43 HEAD / HTTP/1.1
44 User-Agent: PECL::HTTP/2.0.0dev (PHP/5.5.5)
45 Host: pecl.php.net
46 Accept: */*
47 Content-Length: 0
48
49 HTTP/1.1 200 OK
50 Date: Mon, 04 Nov 2013 14:34:02 GMT
51 Server: ...
52 X-Powered-By: PHP/5.2.17
53 Set-Cookie: ...
54 Expires: Thu, 19 Nov 1981 08:52:00 GMT
55 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
56 Pragma: no-cache
57 Connection: close
58 Content-Type: text/html; charset=ISO-8859-1
59 Content-Length: 0
60
61 HEAD / HTTP/1.1
62 User-Agent: PECL::HTTP/2.0.0dev (PHP/5.5.5)
63 Host: php.net
64 Accept: */*
65 Content-Length: 0
66
67 HTTP/1.1 200 OK
68 Server: ...
69 Date: Mon, 04 Nov 2013 14:34:08 GMT
70 Content-Type: text/html;charset=utf-8
71 Connection: keep-alive
72 X-Powered-By: PHP/5.5.4-1
73 Content-Language: en
74 Set-Cookie: ...
75 Last-Modified: Mon, 04 Nov 2013 21:00:36 GMT
76 Content-Length: 0