1
1
<?php
2
2
/**
3
- * ParseStreamHttpClient - Stream http client
4
- *
5
- * @author Ben Friedman <[email protected] >
3
+ * Class ParseStreamHttpClient | Parse/HttpClients/ParseStreamHttpClient.php
6
4
*/
7
5
8
6
namespace Parse \HttpClients ;
9
7
10
8
use Parse \ParseException ;
11
9
10
+ /**
11
+ * Class ParseStreamHttpClient - Stream http client
12
+ *
13
+ * @author Ben Friedman <[email protected] >
14
+ * @package Parse\HttpClients
15
+ */
12
16
class ParseStreamHttpClient implements ParseHttpable
13
17
{
14
18
/**
15
19
* Stream handle
20
+ *
16
21
* @var ParseStream
17
22
*/
18
23
private $ parseStream ;
19
24
20
25
/**
21
26
* Request Headers
27
+ *
22
28
* @var array
23
29
*/
24
30
private $ headers = array ();
25
31
26
32
/**
27
33
* Response headers
34
+ *
28
35
* @var array
29
36
*/
30
37
private $ responseHeaders = array ();
31
38
32
39
/**
33
40
* Response code
41
+ *
34
42
* @var int
35
43
*/
36
44
private $ responseCode = 0 ;
37
45
38
46
/**
39
47
* Content type of our response
48
+ *
40
49
* @var string|null
41
50
*/
42
51
private $ responseContentType ;
43
52
44
53
/**
45
54
* Stream error code
55
+ *
46
56
* @var int
47
57
*/
48
58
private $ streamErrorCode ;
49
59
50
60
/**
51
61
* Stream error message
62
+ *
52
63
* @var string
53
64
*/
54
65
private $ streamErrorMessage ;
55
66
56
67
/**
57
68
* Options to pass to our stream
69
+ *
58
70
* @var array
59
71
*/
60
72
private $ options = array ();
61
73
62
74
/**
63
75
* Optional CA file to verify our peers with
76
+ *
64
77
* @var string
65
78
*/
66
79
private $ caFile ;
67
80
68
81
/**
69
82
* Response from our request
83
+ *
70
84
* @var string
71
85
*/
72
86
private $ response ;
73
87
88
+ /**
89
+ * ParseStreamHttpClient constructor.
90
+ */
74
91
public function __construct ()
75
92
{
76
93
if (!isset ($ this ->parseStream )) {
@@ -143,6 +160,9 @@ private function buildRequestHeaders()
143
160
return implode ("\r\n" , $ headers );
144
161
}
145
162
163
+ /**
164
+ * Sets up ssl related options for the stream context
165
+ */
146
166
public function setup ()
147
167
{
148
168
// setup ssl options
@@ -154,6 +174,15 @@ public function setup()
154
174
);
155
175
}
156
176
177
+ /**
178
+ * Sends an HTTP request
179
+ *
180
+ * @param string $url Url to send this request to
181
+ * @param string $method Method to send this request via
182
+ * @param array $data Data to send in this request
183
+ * @return string
184
+ * @throws ParseException
185
+ */
157
186
public function send ($ url , $ method = 'GET ' , $ data = array ())
158
187
{
159
188
@@ -287,6 +316,11 @@ public function getErrorMessage()
287
316
return $ this ->streamErrorMessage ;
288
317
}
289
318
319
+ /**
320
+ * Sets a connection timeout. UNUSED in the stream client.
321
+ *
322
+ * @param int $timeout Timeout to set
323
+ */
290
324
public function setConnectionTimeout ($ timeout )
291
325
{
292
326
// do nothing
0 commit comments