1 | <?php |
||
28 | class HttpTransport extends AbstractTransport |
||
29 | { |
||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $host = "127.0.0.1"; |
||
34 | |||
35 | /** |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $port = 12202; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $path = "/gelf"; |
||
44 | |||
45 | /** |
||
46 | * @var StreamSocketClient |
||
47 | */ |
||
48 | protected $socketClient; |
||
49 | |||
50 | /** |
||
51 | * @var SslOptions|null |
||
52 | */ |
||
53 | protected $sslOptions = null; |
||
54 | |||
55 | /** |
||
56 | * @var string|null |
||
57 | */ |
||
58 | protected $authentication = null; |
||
59 | |||
60 | /** |
||
61 | * Class constructor |
||
62 | * |
||
63 | * @param string|null $host when NULL or empty default-host is used |
||
64 | * @param int|null $port when NULL or empty default-port is used |
||
65 | * @param string|null $path when NULL or empty default-path is used |
||
66 | * @param SslOptions|null $sslOptions when null not SSL is used |
||
67 | */ |
||
68 | 15 | public function __construct($host = null, $port = null, $path = null, SslOptions $sslOptions = null) |
|
88 | |||
89 | /** |
||
90 | * Creates a HttpTransport from a URI |
||
91 | * |
||
92 | * Supports http and https schemes, port-, path- and auth-definitions |
||
93 | * If the port is ommitted 80 and 443 are used respectively. |
||
94 | * If a username but no password is given, and empty password is used. |
||
95 | * If a https URI is given, the provided SslOptions (with a fallback to |
||
96 | * the default SslOptions) are used. |
||
97 | * |
||
98 | * @param string $url |
||
99 | * @param SslOptions|null $sslOptions |
||
100 | * |
||
101 | * @return HttpTransport |
||
102 | */ |
||
103 | 3 | public static function fromUrl($url, SslOptions $sslOptions = null) |
|
138 | |||
139 | /** |
||
140 | * Sets HTTP basic authentication |
||
141 | * |
||
142 | * @param string $username |
||
143 | * @param string $password |
||
144 | */ |
||
145 | 2 | public function setAuthentication($username, $password) |
|
149 | |||
150 | /** |
||
151 | * Sends a Message over this transport |
||
152 | * |
||
153 | * @param MessageInterface $message |
||
154 | * |
||
155 | * @return int the number of bytes sent |
||
156 | */ |
||
157 | 6 | public function send(MessageInterface $message) |
|
204 | |||
205 | /** |
||
206 | * @return string |
||
207 | */ |
||
208 | 6 | private function readResponseHeaders() |
|
223 | |||
224 | /** |
||
225 | * @return string |
||
226 | */ |
||
227 | 15 | private function getScheme() |
|
231 | |||
232 | /** |
||
233 | * @return array |
||
234 | */ |
||
235 | 15 | private function getContext() |
|
243 | |||
244 | /** |
||
245 | * Sets the connect-timeout |
||
246 | * |
||
247 | * @param int $timeout |
||
248 | */ |
||
249 | 1 | public function setConnectTimeout($timeout) |
|
253 | |||
254 | /** |
||
255 | * Returns the connect-timeout |
||
256 | * |
||
257 | * @return int |
||
258 | */ |
||
259 | 1 | public function getConnectTimeout() |
|
263 | } |
||
264 |