File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,11 +116,7 @@ public function addOptions(array $params)
116116 */
117117 public function post ($ fields = array (), array $ options = array ())
118118 {
119- $ fields = is_array ($ fields ) ? http_build_query ($ fields ) : $ fields ;
120-
121- $ this ->addOptions ($ options );
122- $ this ->addOptions (array (CURLOPT_POST => true , CURLOPT_POSTFIELDS => $ fields ));
123- return $ this ->_exec ();
119+ return $ this ->get ($ options + array (CURLOPT_POST => true , CURLOPT_POSTFIELDS => is_array ($ fields ) ? http_build_query ($ fields ) : $ fields ));
124120 }
125121
126122 /**
@@ -132,11 +128,7 @@ public function post($fields = array(), array $options = array())
132128 */
133129 public function put ($ fields = array (), array $ options = array ())
134130 {
135- $ fields = is_array ($ fields ) ? http_build_query ($ fields ) : $ fields ;
136-
137- $ this ->addOptions ($ options );
138- $ this ->addOptions (array (CURLOPT_CUSTOMREQUEST => 'PUT ' , CURLOPT_POSTFIELDS => $ fields ));
139- return $ this ->_exec ();
131+ return $ this ->get ($ options + array (CURLOPT_CUSTOMREQUEST => 'PUT ' , CURLOPT_POSTFIELDS => is_array ($ fields ) ? http_build_query ($ fields ) : $ fields ));
140132 }
141133
142134 /**
@@ -159,9 +151,7 @@ public function get(array $options = array())
159151 */
160152 public function delete (array $ options = array ())
161153 {
162- $ this ->addOptions ($ options );
163- $ this ->addOptions (array (CURLOPT_CUSTOMREQUEST => 'DELETE ' ));
164- return $ this ->_exec ();
154+ return $ this ->get ($ options + array (CURLOPT_CUSTOMREQUEST => 'DELETE ' ));
165155 }
166156
167157 /**
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ public function testGetRequest()
3030 public function testPostRequest ()
3131 {
3232 $ http = new dHttp \Client ('http://php.net ' );
33- $ resp = $ http ->post ();
34-
33+ $ resp = $ http ->post ([], [ CURLOPT_HEADER => true ] );
34+
3535 $ this ->assertInstanceOf ('dHttp\Response ' , $ resp );
3636 $ this ->assertEquals ($ resp ->getCode (), 200 );
3737 }
You can’t perform that action at this time.
0 commit comments