Changeset 13018
- Timestamp:
- 11/15/08 22:12:39 (1 year ago)
- Files:
-
- branches/1.2/lib/request/sfWebRequest.class.php (modified) (4 diffs)
- branches/1.2/test/unit/request/sfWebRequestTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.2/lib/request/sfWebRequest.class.php
r11954 r13018 592 592 * @return array Path information 593 593 */ 594 p rotectedfunction getPathInfoArray()594 public function getPathInfoArray() 595 595 { 596 596 if (!$this->pathInfoArray) … … 767 767 768 768 /** 769 * Returns the remote IP address forthe request.769 * Returns the remote IP address that made the request. 770 770 * 771 771 * @return string The remote IP address … … 779 779 780 780 /** 781 * Returns the remote IP addressed after resolved from the forward. 782 * 783 * This is useful if you are testing to see if the user is behind a proxy. However, 784 * it should not be trusted. 785 * 786 * @return string|null The remote IP address resolved from a forward, null if none set 787 */ 788 public function getForwardedRemoteAddress() 781 * Returns an array containing a list of IPs, the first being the client address 782 * and the others the addresses of each proxy that passed the request. The address 783 * for the last proxy can be retrieved via getRemoteAddress(). 784 * 785 * This method returns null if no proxy passed this request. Note that some proxies 786 * do not use this header, and act as if they were the client. 787 * 788 * @return string|null An array of IP from the client and the proxies that passed 789 * the request, or null if no proxy was used. 790 */ 791 public function getForwardedFor() 789 792 { 790 793 $pathInfo = $this->getPathInfoArray(); … … 795 798 } 796 799 797 return $pathInfo['HTTP_X_FORWARDED_FOR'];800 return split(', ', $pathInfo['HTTP_X_FORWARDED_FOR']); 798 801 } 799 802 branches/1.2/test/unit/request/sfWebRequestTest.php
r11254 r13018 138 138 $t->is($request->getRemoteAddress(), '127.0.0.1', '->getRemoteAddress() returns the remote address'); 139 139 140 // ->getForwarded RemoteAddress()141 $t->diag('->getForwarded RemoteAddress()');142 $t->is($request->getForwarded RemoteAddress(), null, '->getForwardedRemoteAddress() returns null if the request was not forwarded.');143 $_SERVER['HTTP_X_FORWARDED_FOR'] = '10.0.0.1 ';144 $t->is ($request->getForwardedRemoteAddress(), '10.0.0.1', '->getForwardedRemoteAddress() returns the value from HTTP_X_FORWARDED_FOR');140 // ->getForwardedFor() 141 $t->diag('->getForwardedFor()'); 142 $t->is($request->getForwardedFor(), null, '->getForwardedFor() returns null if the request was not forwarded.'); 143 $_SERVER['HTTP_X_FORWARDED_FOR'] = '10.0.0.1, 10.0.0.2'; 144 $t->is_deeply($request->getForwardedFor(), array('10.0.0.1', '10.0.0.2'), '->getForwardedFor() returns the value from HTTP_X_FORWARDED_FOR'); 145 145 146 146 // methods

