|
16 | 16 | /** |
17 | 17 | * Class BackgroundRequest |
18 | 18 | * |
19 | | - * @package nguyenanhung\MyRequests |
20 | | - * @author 713uk13m <[email protected]> |
21 | | - * @copyright 713uk13m <[email protected]> |
| 19 | + * @package nguyenanhung\MyRequests |
| 20 | + * @author 713uk13m <[email protected]> |
| 21 | + * @copyright 713uk13m <[email protected]> |
22 | 22 | */ |
23 | 23 | class BackgroundRequest implements ProjectInterface, BackgroundRequestInterface |
24 | 24 | { |
| 25 | + const REQUEST_TIMEOUT = 30; |
| 26 | + const PORT_SSL = 443; |
| 27 | + const PORT_HTTP = 80; |
| 28 | + |
25 | 29 | use Version; |
26 | 30 |
|
27 | 31 | /** @var object \nguyenanhung\MyDebug\Benchmark */ |
@@ -90,9 +94,9 @@ public static function backgroundHttpGet($url) |
90 | 94 | { |
91 | 95 | $parts = parse_url($url); |
92 | 96 | if (strtolower($parts['scheme']) == 'https') { |
93 | | - $fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : 443, $errno, $errStr, 30); |
| 97 | + $fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : self::PORT_SSL, $errno, $errStr, self::REQUEST_TIMEOUT); |
94 | 98 | } else { |
95 | | - $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errStr, 30); |
| 99 | + $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : self::PORT_HTTP, $errno, $errStr, self::REQUEST_TIMEOUT); |
96 | 100 | } |
97 | 101 | if (!$fp) { |
98 | 102 | if (function_exists('log_message')) { |
@@ -128,9 +132,9 @@ public static function backgroundHttpPost($url, $paramString = '') |
128 | 132 | { |
129 | 133 | $parts = parse_url($url); |
130 | 134 | if ($parts['scheme'] == 'https') { |
131 | | - $fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : 443, $errno, $errStr, 30); |
| 135 | + $fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : self::PORT_SSL, $errno, $errStr, self::REQUEST_TIMEOUT); |
132 | 136 | } else { |
133 | | - $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errStr, 30); |
| 137 | + $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : self::PORT_HTTP, $errno, $errStr, self::REQUEST_TIMEOUT); |
134 | 138 | } |
135 | 139 | if (!$fp) { |
136 | 140 | if (function_exists('log_message')) { |
|
0 commit comments