Skip to content

Instantly share code, notes, and snippets.

@simoncpu
Created April 19, 2011 10:11
Show Gist options
  • Save simoncpu/927088 to your computer and use it in GitHub Desktop.
Save simoncpu/927088 to your computer and use it in GitHub Desktop.
support for AgaviWebRequest::getUrlPort() behind a proxy
--- AgaviWebRequest.class.php 2011-04-19 18:06:22.000000000 +0800
+++ AgaviWebRequest.class.php.orig 2011-04-19 17:30:15.000000000 +0800
@@ -327,7 +327,6 @@
'SERVER_PORT' => 'SERVER_PORT',
'SERVER_PROTOCOL' => 'SERVER_PROTOCOL',
'SERVER_SOFTWARE' => 'SERVER_SOFTWARE',
- 'HTTP_HOST' => 'HTTP_HOST',
), (array)$this->getParameter('sources'));
$this->setParameter('sources', $sources);
@@ -339,7 +338,6 @@
'SERVER_PORT' => isset($parameters['sources']['SERVER_PORT']) ? null : $this->urlPort,
'SERVER_PROTOCOL' => isset($parameters['sources']['SERVER_PROTOCOL']) ? null : 'HTTP/1.0',
'SERVER_SOFTWARE' => null,
- 'HTTP_HOST' => null,
);
$methods = array_merge(array(
@@ -362,8 +360,7 @@
$this->urlScheme = 'http' . (strtolower($HTTPS) == 'on' ? 's' : '');
- preg_match('/(.*):(.*)/', self::getSourceValue($sources['HTTP_HOST'], $sourceDefaults['HTTP_HOST']), $tmp);
- $this->urlPort = isset($tmp[2]) ? (int)$tmp[2] : (int)self::getSourceValue($sources['SERVER_PORT'], $sourceDefaults['SERVER_PORT']);
+ $this->urlPort = (int)self::getSourceValue($sources['SERVER_PORT'], $sourceDefaults['SERVER_PORT']);
$SERVER_NAME = self::getSourceValue($sources['SERVER_NAME'], $sourceDefaults['SERVER_NAME']);
$port = $this->getUrlPort();
@@ -533,4 +530,4 @@
}
}
-?>
+?>
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment