11<?php
22/**
3- * Zend Framework
3+ * Zend Framework (http://framework.zend.com/)
44 *
5- * LICENSE
6- *
7- * This source file is subject to the new BSD license that is bundled
8- * with this package in the file LICENSE.txt.
9- * It is also available through the world-wide-web at this URL:
10- * http://framework.zend.com/license/new-bsd
11- * If you did not receive a copy of the license and are unable to
12- * obtain it through the world-wide-web, please send an email
13- * to license@zend.com so we can send you a copy immediately.
14- *
15- * @category Zend
16- * @package Zend\Http
17- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
18- * @license http://framework.zend.com/license/new-bsd New BSD License
5+ * @link http://github.com/zendframework/zf2 for the canonical source repository
6+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
7+ * @license http://framework.zend.com/license/new-bsd New BSD License
8+ * @package Zend_Http
199 */
2010
2111namespace Zend \Http ;
2212
13+ use ArrayIterator ;
2314use Traversable ;
15+ use Zend \Stdlib ;
2416use Zend \Stdlib \ArrayUtils ;
25- use ArrayIterator ,
26- Zend \Uri \Http ,
27- Zend \Stdlib ;
17+ use Zend \Uri \Http ;
2818
2919/**
3020 * Http client
3121 *
3222 * @category Zend
3323 * @package Zend\Http
34- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
35- * @license http://framework.zend.com/license/new-bsd New BSD License
3624 */
3725class Client implements Stdlib \DispatchableInterface
3826{
@@ -135,7 +123,7 @@ class Client implements Stdlib\DispatchableInterface
135123 *
136124 * @var resource
137125 */
138- static protected $ _fileInfoDb = null ;
126+ protected static $ _fileInfoDb = null ;
139127
140128 /**
141129 * Constructor
@@ -334,7 +322,7 @@ public function setUri($uri)
334322 */
335323 public function getUri ()
336324 {
337- return $ this ->getRequest ()->uri ();
325+ return $ this ->getRequest ()->getUri ();
338326 }
339327
340328 /**
@@ -415,7 +403,7 @@ public function setRawBody($body)
415403 */
416404 public function setParameterPost (array $ post )
417405 {
418- $ this ->getRequest ()->post ()->fromArray ($ post );
406+ $ this ->getRequest ()->getPost ()->fromArray ($ post );
419407 return $ this ;
420408 }
421409
@@ -427,7 +415,7 @@ public function setParameterPost(array $post)
427415 */
428416 public function setParameterGet (array $ query )
429417 {
430- $ this ->getRequest ()->query ()->fromArray ($ query );
418+ $ this ->getRequest ()->getQuery ()->fromArray ($ query );
431419 return $ this ;
432420 }
433421
@@ -545,7 +533,7 @@ public function setHeaders($headers)
545533 */
546534 public function hasHeader ($ name )
547535 {
548- $ headers = $ this ->getRequest ()->headers ();
536+ $ headers = $ this ->getRequest ()->getHeaders ();
549537
550538 if ($ headers instanceof Headers) {
551539 return $ headers ->has ($ name );
@@ -562,7 +550,7 @@ public function hasHeader($name)
562550 */
563551 public function getHeader ($ name )
564552 {
565- $ headers = $ this ->getRequest ()->headers ();
553+ $ headers = $ this ->getRequest ()->getHeaders ();
566554
567555 if ($ headers instanceof Headers) {
568556 if ($ headers ->get ($ name )) {
@@ -766,7 +754,7 @@ public function send(Request $request = null)
766754 $ uri = $ this ->getUri ();
767755
768756 // query
769- $ query = $ this ->getRequest ()->query ();
757+ $ query = $ this ->getRequest ()->getQuery ();
770758
771759 if (!empty ($ query )) {
772760 $ queryArray = $ query ->toArray ();
@@ -855,17 +843,17 @@ public function send(Request $request = null)
855843 }
856844
857845 // Get the cookies from response (if any)
858- $ setCookie = $ response ->cookie ();
846+ $ setCookie = $ response ->getCookie ();
859847 if (!empty ($ setCookie )) {
860848 $ this ->addCookie ($ setCookie );
861849 }
862850
863851 // If we got redirected, look for the Location header
864- if ($ response ->isRedirect () && ($ response ->headers ()->has ('Location ' ))) {
852+ if ($ response ->isRedirect () && ($ response ->getHeaders ()->has ('Location ' ))) {
865853
866854 // Avoid problems with buggy servers that add whitespace at the
867855 // end of some headers
868- $ location = trim ($ response ->headers ()->get ('Location ' )->getFieldValue ());
856+ $ location = trim ($ response ->getHeaders ()->get ('Location ' )->getFieldValue ());
869857
870858 // Check whether we send the exact same request again, or drop the parameters
871859 // and send a GET request
@@ -946,7 +934,7 @@ public function setFileUpload($filename, $formname, $data = null, $ctype = null)
946934 }
947935 }
948936
949- $ this ->getRequest ()->file ()->set ($ filename , array (
937+ $ this ->getRequest ()->getFile ()->set ($ filename , array (
950938 'formname ' => $ formname ,
951939 'filename ' => basename ($ filename ),
952940 'ctype ' => $ ctype ,
@@ -964,9 +952,9 @@ public function setFileUpload($filename, $formname, $data = null, $ctype = null)
964952 */
965953 public function removeFileUpload ($ filename )
966954 {
967- $ file = $ this ->getRequest ()->file ()->get ($ filename );
955+ $ file = $ this ->getRequest ()->getFile ()->get ($ filename );
968956 if (!empty ($ file )) {
969- $ this ->getRequest ()->file ()->set ($ filename , null );
957+ $ this ->getRequest ()->getFile ()->set ($ filename , null );
970958 return true ;
971959 }
972960 return false ;
@@ -1026,7 +1014,7 @@ protected function prepareHeaders($body, $uri)
10261014 }
10271015
10281016 // Set the connection header
1029- if (!$ this ->getRequest ()->headers ()->has ('Connection ' )) {
1017+ if (!$ this ->getRequest ()->getHeaders ()->has ('Connection ' )) {
10301018 if (!$ this ->config ['keepalive ' ]) {
10311019 $ headers ['Connection ' ] = 'close ' ;
10321020 }
@@ -1044,7 +1032,7 @@ protected function prepareHeaders($body, $uri)
10441032
10451033
10461034 // Set the user agent header
1047- if (!$ this ->getRequest ()->headers ()->has ('User-Agent ' ) && isset ($ this ->config ['useragent ' ])) {
1035+ if (!$ this ->getRequest ()->getHeaders ()->has ('User-Agent ' ) && isset ($ this ->config ['useragent ' ])) {
10481036 $ headers ['User-Agent ' ] = $ this ->config ['useragent ' ];
10491037 }
10501038
@@ -1078,7 +1066,7 @@ protected function prepareHeaders($body, $uri)
10781066 }
10791067
10801068 // Merge the headers of the request (if any)
1081- $ requestHeaders = $ this ->getRequest ()->headers ()->toArray ();
1069+ $ requestHeaders = $ this ->getRequest ()->getHeaders ()->toArray ();
10821070 foreach ($ requestHeaders as $ key => $ value ) {
10831071 $ headers [$ key ] = $ value ;
10841072 }
@@ -1107,8 +1095,8 @@ protected function prepareBody()
11071095 $ body = '' ;
11081096 $ totalFiles = 0 ;
11091097
1110- if (!$ this ->getRequest ()->headers ()->has ('Content-Type ' )) {
1111- $ totalFiles = count ($ this ->getRequest ()->file ()->toArray ());
1098+ if (!$ this ->getRequest ()->getHeaders ()->has ('Content-Type ' )) {
1099+ $ totalFiles = count ($ this ->getRequest ()->getFile ()->toArray ());
11121100 // If we have files to upload, force encType to multipart/form-data
11131101 if ($ totalFiles > 0 ) {
11141102 $ this ->setEncType (self ::ENC_FORMDATA );
@@ -1118,26 +1106,26 @@ protected function prepareBody()
11181106 }
11191107
11201108 // If we have POST parameters or files, encode and add them to the body
1121- if (count ($ this ->getRequest ()->post ()->toArray ()) > 0 || $ totalFiles > 0 ) {
1109+ if (count ($ this ->getRequest ()->getPost ()->toArray ()) > 0 || $ totalFiles > 0 ) {
11221110 if (stripos ($ this ->getEncType (), self ::ENC_FORMDATA ) === 0 ) {
11231111 $ boundary = '---ZENDHTTPCLIENT- ' . md5 (microtime ());
11241112 $ this ->setEncType (self ::ENC_FORMDATA , $ boundary );
11251113
11261114 // Get POST parameters and encode them
1127- $ params = self ::flattenParametersArray ($ this ->getRequest ()->post ()->toArray ());
1115+ $ params = self ::flattenParametersArray ($ this ->getRequest ()->getPost ()->toArray ());
11281116 foreach ($ params as $ pp ) {
11291117 $ body .= $ this ->encodeFormData ($ boundary , $ pp [0 ], $ pp [1 ]);
11301118 }
11311119
11321120 // Encode files
1133- foreach ($ this ->getRequest ()->file ()->toArray () as $ key => $ file ) {
1121+ foreach ($ this ->getRequest ()->getFile ()->toArray () as $ key => $ file ) {
11341122 $ fhead = array ('Content-Type ' => $ file ['ctype ' ]);
11351123 $ body .= $ this ->encodeFormData ($ boundary , $ file ['formname ' ], $ file ['data ' ], $ file ['filename ' ], $ fhead );
11361124 }
11371125 $ body .= "-- {$ boundary }-- \r\n" ;
11381126 } elseif (stripos ($ this ->getEncType (), self ::ENC_URLENCODED ) === 0 ) {
11391127 // Encode body as application/x-www-form-urlencoded
1140- $ body = http_build_query ($ this ->getRequest ()->post ()->toArray ());
1128+ $ body = http_build_query ($ this ->getRequest ()->getPost ()->toArray ());
11411129 } else {
11421130 throw new Client \Exception \RuntimeException ("Cannot handle content type ' {$ this ->encType }' automatically " );
11431131 }
0 commit comments