flush
[mdref/mdref-http] / http / Client / notify.md
1 # http\Client http\Client::notify([http\Client\Request $request = NULL[, object $progress = NULL]])
2
3 Implements SplSubject. Notify attached observers about progress with $request.
4
5 ## Params:
6
7 * Optional http\Client\Request $request = NULL
8 The request to notify about.
9 * Optional object $progress = NULL
10 stdClass instance holding progress information.
11
12 ## Returns:
13
14 * http\Client, self.
15
16 ## Example:
17
18 <?php
19 class Observer implements SplObserver {
20 function update(SplSubject $client, http\Client\Request $request = NULL, $progress = NULL) {
21 printf("%s %d%%\n", $progress->info,
22 $progress->dltotal ? ($progress->dlnow*100/$progress->dltotal) : 0);
23 }
24 }
25
26 $client = new http\Client;
27
28 $client->attach(new Observer);
29 $client->enqueue(new http\Client\Request("GET", "https://php.net/images/logos/php-logo.eps"));
30 $client->send();
31 ?>
32
33 May yield:
34
35 start 0%
36 setup 0%
37 setup 0%
38 setup 0%
39 setup 0%
40 setup 0%
41 resolve 0%
42 connect 0%
43 connected 0%
44 connected 0%
45 connected 0%
46 ssl negotiation 0%
47 ssl negotiation 0%
48 ssl negotiation 0%
49 ssl negotiation 0%
50 ssl negotiation 0%
51 ssl negotiation 0%
52 ssl negotiation 0%
53 ssl negotiation 0%
54 ssl negotiation 0%
55 ssl negotiation 0%
56 ssl negotiation 0%
57 ssl negotiation 0%
58 ssl negotiation 0%
59 ssl negotiation 0%
60 ssl negotiation 0%
61 ssl negotiation 0%
62 ssl negotiation 0%
63 ssl negotiation 0%
64 blacklist check 0%
65 receive 10%
66 receive 20%
67 receive 30%
68 receive 40%
69 receive 50%
70 receive 60%
71 receive 70%
72 receive 80%
73 receive 90%
74 receive 100%
75 receive 100%
76 not disconnected 100%
77 finished 100%