Mercurial > hg > cmmr2012-drupal-site
comparison vendor/zendframework/zend-feed/src/PubSubHubbub/AbstractCallback.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | 5311817fb629 |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
209 */ | 209 */ |
210 // @codingStandardsIgnoreStart | 210 // @codingStandardsIgnoreStart |
211 protected function _detectCallbackUrl() | 211 protected function _detectCallbackUrl() |
212 { | 212 { |
213 // @codingStandardsIgnoreEnd | 213 // @codingStandardsIgnoreEnd |
214 $callbackUrl = ''; | 214 $callbackUrl = null; |
215 if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { | 215 |
216 $callbackUrl = $_SERVER['HTTP_X_ORIGINAL_URL']; | 216 // IIS7 with URL Rewrite: make sure we get the unencoded url |
217 } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { | 217 // (double slash problem). |
218 $callbackUrl = $_SERVER['HTTP_X_REWRITE_URL']; | 218 $iisUrlRewritten = isset($_SERVER['IIS_WasUrlRewritten']) ? $_SERVER['IIS_WasUrlRewritten'] : null; |
219 } elseif (isset($_SERVER['REQUEST_URI'])) { | 219 $unencodedUrl = isset($_SERVER['UNENCODED_URL']) ? $_SERVER['UNENCODED_URL'] : null; |
220 $callbackUrl = $_SERVER['REQUEST_URI']; | 220 if ('1' == $iisUrlRewritten && ! empty($unencodedUrl)) { |
221 $scheme = 'http'; | 221 return $unencodedUrl; |
222 if ($_SERVER['HTTPS'] == 'on') { | 222 } |
223 $scheme = 'https'; | 223 |
224 } | 224 // HTTP proxy requests setup request URI with scheme and host [and port] |
225 $schemeAndHttpHost = $scheme . '://' . $this->_getHttpHost(); | 225 // + the URL path, only use URL path. |
226 if (strpos($callbackUrl, $schemeAndHttpHost) === 0) { | 226 if (isset($_SERVER['REQUEST_URI'])) { |
227 $callbackUrl = substr($callbackUrl, strlen($schemeAndHttpHost)); | 227 $callbackUrl = $this->buildCallbackUrlFromRequestUri(); |
228 } | 228 } |
229 } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { | 229 |
230 $callbackUrl = $_SERVER['ORIG_PATH_INFO']; | 230 if (null !== $callbackUrl) { |
231 if (! empty($_SERVER['QUERY_STRING'])) { | 231 return $callbackUrl; |
232 $callbackUrl .= '?' . $_SERVER['QUERY_STRING']; | 232 } |
233 } | 233 |
234 } | 234 if (isset($_SERVER['ORIG_PATH_INFO'])) { |
235 return $callbackUrl; | 235 return $this->buildCallbackUrlFromOrigPathInfo(); |
236 } | |
237 | |
238 return ''; | |
236 } | 239 } |
237 | 240 |
238 /** | 241 /** |
239 * Get the HTTP host | 242 * Get the HTTP host |
240 * | 243 * |
245 { | 248 { |
246 // @codingStandardsIgnoreEnd | 249 // @codingStandardsIgnoreEnd |
247 if (! empty($_SERVER['HTTP_HOST'])) { | 250 if (! empty($_SERVER['HTTP_HOST'])) { |
248 return $_SERVER['HTTP_HOST']; | 251 return $_SERVER['HTTP_HOST']; |
249 } | 252 } |
250 $scheme = 'http'; | 253 |
251 if ($_SERVER['HTTPS'] == 'on') { | 254 $https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : null; |
252 $scheme = 'https'; | 255 $scheme = $https === 'on' ? 'https' : 'http'; |
253 } | 256 $name = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; |
254 $name = $_SERVER['SERVER_NAME']; | 257 $port = isset($_SERVER['SERVER_PORT']) ? (int) $_SERVER['SERVER_PORT'] : 80; |
255 $port = $_SERVER['SERVER_PORT']; | 258 |
256 if (($scheme == 'http' && $port == 80) | 259 if (($scheme === 'http' && $port === 80) |
257 || ($scheme == 'https' && $port == 443) | 260 || ($scheme === 'https' && $port === 443) |
258 ) { | 261 ) { |
259 return $name; | 262 return $name; |
260 } | 263 } |
261 | 264 |
262 return $name . ':' . $port; | 265 return sprintf('%s:%d', $name, $port); |
263 } | 266 } |
264 | 267 |
265 /** | 268 /** |
266 * Retrieve a Header value from either $_SERVER or Apache | 269 * Retrieve a Header value from either $_SERVER or Apache |
267 * | 270 * |
302 ? stream_get_contents($this->inputStream) | 305 ? stream_get_contents($this->inputStream) |
303 : file_get_contents($this->inputStream); | 306 : file_get_contents($this->inputStream); |
304 | 307 |
305 return strlen(trim($body)) > 0 ? $body : false; | 308 return strlen(trim($body)) > 0 ? $body : false; |
306 } | 309 } |
310 | |
311 /** | |
312 * Build the callback URL from the REQUEST_URI server parameter. | |
313 * | |
314 * @return string | |
315 */ | |
316 private function buildCallbackUrlFromRequestUri() | |
317 { | |
318 $callbackUrl = $_SERVER['REQUEST_URI']; | |
319 $https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : null; | |
320 $scheme = $https === 'on' ? 'https' : 'http'; | |
321 if ($https === 'on') { | |
322 $scheme = 'https'; | |
323 } | |
324 $schemeAndHttpHost = $scheme . '://' . $this->_getHttpHost(); | |
325 if (strpos($callbackUrl, $schemeAndHttpHost) === 0) { | |
326 $callbackUrl = substr($callbackUrl, strlen($schemeAndHttpHost)); | |
327 } | |
328 return $callbackUrl; | |
329 } | |
330 | |
331 /** | |
332 * Build the callback URL from the ORIG_PATH_INFO server parameter. | |
333 * | |
334 * @return string | |
335 */ | |
336 private function buildCallbackUrlFromOrigPathInfo() | |
337 { | |
338 $callbackUrl = $_SERVER['ORIG_PATH_INFO']; | |
339 if (! empty($_SERVER['QUERY_STRING'])) { | |
340 $callbackUrl .= '?' . $_SERVER['QUERY_STRING']; | |
341 } | |
342 return $callbackUrl; | |
343 } | |
307 } | 344 } |