diff --git a/extend/catcher/library/client/Http.php b/extend/catcher/library/client/Http.php index 59b8b3b..f87d363 100644 --- a/extend/catcher/library/client/Http.php +++ b/extend/catcher/library/client/Http.php @@ -217,9 +217,8 @@ class Http */ public function get(string $url) { - return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, array_merge($this->header, $this->query, $this->timeout, $this->options))); + return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, $this->merge())); } - /** * Request post * @@ -229,9 +228,7 @@ class Http */ public function post(string $url) { - return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, array_merge( - $this->header, $this->body, $this->formParams, $this->json, $this->timeout, $this->multipart,$this->options - ))); + return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, $this->merge())); } /** @@ -243,9 +240,7 @@ class Http */ public function put(string $url) { - return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, array_merge( - $this->header, $this->body, $this->formParams, $this->json, $this->timeout, $this->options - ))); + return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, $this->merge())); } /** @@ -257,9 +252,21 @@ class Http */ public function delete(string $url) { - return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, array_merge( - $this->header, $this->query, $this->timeout, $this->options - ))); + return new Response($this->getClient()->{$this->asyncMethod(__FUNCTION__)}($url, $this->merge())); + } + + + /** + * request params merge + * + * @time 2020年05月22日 + * @return array + */ + protected function merge() + { + return array_merge($this->header, $this->query, $this->timeout, + $this->options, $this->body, $this->auth, $this->multipart, $this->formParams + ); } /** diff --git a/extend/catcher/library/client/Response.php b/extend/catcher/library/client/Response.php index 975e8e6..d7ab9df 100644 --- a/extend/catcher/library/client/Response.php +++ b/extend/catcher/library/client/Response.php @@ -34,6 +34,17 @@ class Response implements \ArrayAccess return $this->response->getBody(); } + /** + * 响应内容 + * + * @time 2020年05月22日 + * @return false|string + */ + public function contents() + { + return $this->body()->getContents(); + } + /** * * @time 2020年05月21日 @@ -41,7 +52,7 @@ class Response implements \ArrayAccess */ public function json():array { - return \json_decode($this->response->getBody()->getContents(), true); + return \json_decode($this->contents(), true); } /**