Changeset 32729 for branches/1.3
- Timestamp:
- 07/05/11 17:23:04 (2 years ago)
- Files:
-
- branches/1.3/lib/request/sfWebRequest.class.php (modified) (1 diff)
- branches/1.3/test/unit/request/sfWebRequestTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.3/lib/request/sfWebRequest.class.php
r30900 r32729 356 356 $pathArray = $this->getPathInfoArray(); 357 357 358 return isset($pathArray['HTTP_X_FORWARDED_HOST']) ? $pathArray['HTTP_X_FORWARDED_HOST'] : (isset($pathArray['HTTP_HOST']) ? $pathArray['HTTP_HOST'] : ''); 358 if (isset($pathArray['HTTP_X_FORWARDED_HOST'])) 359 { 360 $elements = explode(',', $pathArray['HTTP_X_FORWARDED_HOST']); 361 362 return trim($elements[count($elements) - 1]); 363 } 364 else 365 { 366 return isset($pathArray['HTTP_HOST']) ? $pathArray['HTTP_HOST'] : ''; 367 } 359 368 } 360 369 branches/1.3/test/unit/request/sfWebRequestTest.php
r30900 r32729 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(7 1);13 $t = new lime_test(72); 14 14 15 15 class myRequest extends sfWebRequest … … 368 368 $t->is($request->getContentType(), 'text/html', '->getContentType() strips the charset information by default'); 369 369 $t->is($request->getContentType(false), 'text/html; charset=UTF-8', '->getContentType() does not strip the charset information by defaultif you pass false as the first argument'); 370 371 // ->getHost() 372 $t->diag('->getHost()'); 373 374 $request = new myRequest($dispatcher); 375 $_SERVER['HTTP_X_FORWARDED_HOST'] = 'example1.com, example2.com, example3.com'; 376 $t->is($request->getHost(), 'example3.com', '->getHost() returns the last forwarded host'); 377 unset($_SERVER['HTTP_X_FORWARDED_HOST']);