This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
library/Zend/Controller/Request
tests/Zend/Controller/Request Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -986,8 +986,18 @@ public function getHeader($header)
986
986
}
987
987
988
988
// Try to get it from the $_SERVER array first
989
- $ temp = 'HTTP_ ' . strtoupper (str_replace ('- ' , '_ ' , $ header ));
990
- if (isset ($ _SERVER [$ temp ])) {
989
+ $ temp = strtoupper (str_replace ('- ' , '_ ' , $ header ));
990
+ if (isset ($ _SERVER ['HTTP_ ' . $ temp ])) {
991
+ return $ _SERVER ['HTTP_ ' . $ temp ];
992
+ }
993
+
994
+ /*
995
+ * Try to get it from the $_SERVER array on POST request or CGI environment
996
+ * @see https://www.ietf.org/rfc/rfc3875 (4.1.2. and 4.1.3.)
997
+ */
998
+ if (isset ($ _SERVER [$ temp ])
999
+ && in_array ($ temp , array ('CONTENT_TYPE ' , 'CONTENT_LENGTH ' ))
1000
+ ) {
991
1001
return $ _SERVER [$ temp ];
992
1002
}
993
1003
Original file line number Diff line number Diff line change @@ -660,6 +660,22 @@ public function testGetHeader()
660
660
$ this ->assertFalse ($ this ->_request ->getHeader ('X-No-Such-Thing ' ));
661
661
}
662
662
663
+ /**
664
+ * @see https://www.ietf.org/rfc/rfc3875 (4.1.2. and 4.1.3.)
665
+ */
666
+ public function testGetContentHeadersOnPostRequest ()
667
+ {
668
+ $ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
669
+ $ _SERVER ['CONTENT_LENGTH ' ] = 100 ;
670
+ $ _SERVER ['CONTENT_TYPE ' ] = 'application/x-www-form-urlencoded ' ;
671
+
672
+ $ this ->assertEquals (100 , $ this ->_request ->getHeader ('Content-Length ' ));
673
+ $ this ->assertEquals (
674
+ 'application/x-www-form-urlencoded ' ,
675
+ $ this ->_request ->getHeader ('Content-Type ' )
676
+ );
677
+ }
678
+
663
679
public function testGetHeaderThrowsExceptionWithNoInput ()
664
680
{
665
681
try {
You can’t perform that action at this time.
0 commit comments