1 | <?php |
||
28 | class HttpTransport extends AbstractTransport |
||
29 | { |
||
30 | const DEFAULT_HOST = "127.0.0.1"; |
||
31 | const DEFAULT_PORT = 12202; |
||
32 | const DEFAULT_PATH = "/gelf"; |
||
33 | |||
34 | const AUTO_SSL_PORT = 443; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $host; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $port; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $path; |
||
50 | |||
51 | /** |
||
52 | * @var StreamSocketClient |
||
53 | */ |
||
54 | protected $socketClient; |
||
55 | |||
56 | /** |
||
57 | * @var SslOptions|null |
||
58 | */ |
||
59 | protected $sslOptions = null; |
||
60 | |||
61 | /** |
||
62 | * @var string|null |
||
63 | */ |
||
64 | protected $authentication = null; |
||
65 | |||
66 | /** |
||
67 | * Class constructor |
||
68 | * |
||
69 | * @param string|null $host when NULL or empty default-host is used |
||
70 | * @param int|null $port when NULL or empty default-port is used |
||
|
|||
71 | * @param string|null $path when NULL or empty default-path is used |
||
72 | * @param SslOptions|null $sslOptions when null not SSL is used |
||
73 | */ |
||
74 | 15 | public function __construct( |
|
98 | |||
99 | /** |
||
100 | * Creates a HttpTransport from a URI |
||
101 | * |
||
102 | * Supports http and https schemes, port-, path- and auth-definitions |
||
103 | * If the port is ommitted 80 and 443 are used respectively. |
||
104 | * If a username but no password is given, and empty password is used. |
||
105 | * If a https URI is given, the provided SslOptions (with a fallback to |
||
106 | * the default SslOptions) are used. |
||
107 | * |
||
108 | * @param string $url |
||
109 | * @param SslOptions|null $sslOptions |
||
110 | * |
||
111 | * @return HttpTransport |
||
112 | */ |
||
113 | 3 | public static function fromUrl($url, SslOptions $sslOptions = null) |
|
148 | |||
149 | /** |
||
150 | * Sets HTTP basic authentication |
||
151 | * |
||
152 | * @param string $username |
||
153 | * @param string $password |
||
154 | */ |
||
155 | 2 | public function setAuthentication($username, $password) |
|
159 | |||
160 | /** |
||
161 | * Sends a Message over this transport |
||
162 | * |
||
163 | * @param MessageInterface $message |
||
164 | * |
||
165 | * @return int the number of bytes sent |
||
166 | */ |
||
167 | 6 | public function send(MessageInterface $message) |
|
214 | |||
215 | /** |
||
216 | * @return string |
||
217 | */ |
||
218 | 6 | private function readResponseHeaders() |
|
233 | |||
234 | /** |
||
235 | * @return string |
||
236 | */ |
||
237 | 15 | private function getScheme() |
|
241 | |||
242 | /** |
||
243 | * @return array |
||
244 | */ |
||
245 | 15 | private function getContext() |
|
253 | |||
254 | /** |
||
255 | * Sets the connect-timeout |
||
256 | * |
||
257 | * @param int $timeout |
||
258 | */ |
||
259 | 1 | public function setConnectTimeout($timeout) |
|
263 | |||
264 | /** |
||
265 | * Returns the connect-timeout |
||
266 | * |
||
267 | * @return int |
||
268 | */ |
||
269 | 1 | public function getConnectTimeout() |
|
273 | } |
||
274 |