Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/PubSubHubbub/AbstractCallback.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
65 { | 65 { |
66 if ($options instanceof Traversable) { | 66 if ($options instanceof Traversable) { |
67 $options = ArrayUtils::iteratorToArray($options); | 67 $options = ArrayUtils::iteratorToArray($options); |
68 } | 68 } |
69 | 69 |
70 if (!is_array($options)) { | 70 if (! is_array($options)) { |
71 throw new Exception\InvalidArgumentException('Array or Traversable object' | 71 throw new Exception\InvalidArgumentException('Array or Traversable object' |
72 . 'expected, got ' . gettype($options)); | 72 . 'expected, got ' . gettype($options)); |
73 } | 73 } |
74 | 74 |
75 if (is_array($options)) { | 75 if (is_array($options)) { |
135 * @return AbstractCallback | 135 * @return AbstractCallback |
136 * @throws Exception\InvalidArgumentException | 136 * @throws Exception\InvalidArgumentException |
137 */ | 137 */ |
138 public function setHttpResponse($httpResponse) | 138 public function setHttpResponse($httpResponse) |
139 { | 139 { |
140 if (!$httpResponse instanceof HttpResponse && !$httpResponse instanceof PhpResponse) { | 140 if (! $httpResponse instanceof HttpResponse && ! $httpResponse instanceof PhpResponse) { |
141 throw new Exception\InvalidArgumentException('HTTP Response object must' | 141 throw new Exception\InvalidArgumentException('HTTP Response object must' |
142 . ' implement one of Zend\Feed\Pubsubhubbub\HttpResponse or' | 142 . ' implement one of Zend\Feed\Pubsubhubbub\HttpResponse or' |
143 . ' Zend\Http\PhpEnvironment\Response'); | 143 . ' Zend\Http\PhpEnvironment\Response'); |
144 } | 144 } |
145 $this->httpResponse = $httpResponse; | 145 $this->httpResponse = $httpResponse; |
194 | 194 |
195 /** | 195 /** |
196 * Attempt to detect the callback URL (specifically the path forward) | 196 * Attempt to detect the callback URL (specifically the path forward) |
197 * @return string | 197 * @return string |
198 */ | 198 */ |
199 // @codingStandardsIgnoreStart | |
199 protected function _detectCallbackUrl() | 200 protected function _detectCallbackUrl() |
200 { | 201 { |
202 // @codingStandardsIgnoreEnd | |
201 $callbackUrl = ''; | 203 $callbackUrl = ''; |
202 if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { | 204 if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { |
203 $callbackUrl = $_SERVER['HTTP_X_ORIGINAL_URL']; | 205 $callbackUrl = $_SERVER['HTTP_X_ORIGINAL_URL']; |
204 } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { | 206 } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { |
205 $callbackUrl = $_SERVER['HTTP_X_REWRITE_URL']; | 207 $callbackUrl = $_SERVER['HTTP_X_REWRITE_URL']; |
212 $schemeAndHttpHost = $scheme . '://' . $this->_getHttpHost(); | 214 $schemeAndHttpHost = $scheme . '://' . $this->_getHttpHost(); |
213 if (strpos($callbackUrl, $schemeAndHttpHost) === 0) { | 215 if (strpos($callbackUrl, $schemeAndHttpHost) === 0) { |
214 $callbackUrl = substr($callbackUrl, strlen($schemeAndHttpHost)); | 216 $callbackUrl = substr($callbackUrl, strlen($schemeAndHttpHost)); |
215 } | 217 } |
216 } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { | 218 } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { |
217 $callbackUrl= $_SERVER['ORIG_PATH_INFO']; | 219 $callbackUrl = $_SERVER['ORIG_PATH_INFO']; |
218 if (!empty($_SERVER['QUERY_STRING'])) { | 220 if (! empty($_SERVER['QUERY_STRING'])) { |
219 $callbackUrl .= '?' . $_SERVER['QUERY_STRING']; | 221 $callbackUrl .= '?' . $_SERVER['QUERY_STRING']; |
220 } | 222 } |
221 } | 223 } |
222 return $callbackUrl; | 224 return $callbackUrl; |
223 } | 225 } |
225 /** | 227 /** |
226 * Get the HTTP host | 228 * Get the HTTP host |
227 * | 229 * |
228 * @return string | 230 * @return string |
229 */ | 231 */ |
232 // @codingStandardsIgnoreStart | |
230 protected function _getHttpHost() | 233 protected function _getHttpHost() |
231 { | 234 { |
232 if (!empty($_SERVER['HTTP_HOST'])) { | 235 // @codingStandardsIgnoreEnd |
236 if (! empty($_SERVER['HTTP_HOST'])) { | |
233 return $_SERVER['HTTP_HOST']; | 237 return $_SERVER['HTTP_HOST']; |
234 } | 238 } |
235 $scheme = 'http'; | 239 $scheme = 'http'; |
236 if ($_SERVER['HTTPS'] == 'on') { | 240 if ($_SERVER['HTTPS'] == 'on') { |
237 $scheme = 'https'; | 241 $scheme = 'https'; |
251 * Retrieve a Header value from either $_SERVER or Apache | 255 * Retrieve a Header value from either $_SERVER or Apache |
252 * | 256 * |
253 * @param string $header | 257 * @param string $header |
254 * @return bool|string | 258 * @return bool|string |
255 */ | 259 */ |
260 // @codingStandardsIgnoreStart | |
256 protected function _getHeader($header) | 261 protected function _getHeader($header) |
257 { | 262 { |
263 // @codingStandardsIgnoreEnd | |
258 $temp = strtoupper(str_replace('-', '_', $header)); | 264 $temp = strtoupper(str_replace('-', '_', $header)); |
259 if (!empty($_SERVER[$temp])) { | 265 if (! empty($_SERVER[$temp])) { |
260 return $_SERVER[$temp]; | 266 return $_SERVER[$temp]; |
261 } | 267 } |
262 $temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header)); | 268 $temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header)); |
263 if (!empty($_SERVER[$temp])) { | 269 if (! empty($_SERVER[$temp])) { |
264 return $_SERVER[$temp]; | 270 return $_SERVER[$temp]; |
265 } | 271 } |
266 if (function_exists('apache_request_headers')) { | 272 if (function_exists('apache_request_headers')) { |
267 $headers = apache_request_headers(); | 273 $headers = apache_request_headers(); |
268 if (!empty($headers[$header])) { | 274 if (! empty($headers[$header])) { |
269 return $headers[$header]; | 275 return $headers[$header]; |
270 } | 276 } |
271 } | 277 } |
272 return false; | 278 return false; |
273 } | 279 } |
275 /** | 281 /** |
276 * Return the raw body of the request | 282 * Return the raw body of the request |
277 * | 283 * |
278 * @return string|false Raw body, or false if not present | 284 * @return string|false Raw body, or false if not present |
279 */ | 285 */ |
286 // @codingStandardsIgnoreStart | |
280 protected function _getRawBody() | 287 protected function _getRawBody() |
281 { | 288 { |
289 // @codingStandardsIgnoreEnd | |
282 $body = file_get_contents('php://input'); | 290 $body = file_get_contents('php://input'); |
283 if (strlen(trim($body)) == 0 && isset($GLOBALS['HTTP_RAW_POST_DATA'])) { | 291 if (strlen(trim($body)) == 0 && isset($GLOBALS['HTTP_RAW_POST_DATA'])) { |
284 $body = $GLOBALS['HTTP_RAW_POST_DATA']; | 292 $body = $GLOBALS['HTTP_RAW_POST_DATA']; |
285 } | 293 } |
286 if (strlen(trim($body)) > 0) { | 294 if (strlen(trim($body)) > 0) { |