Skip to content

Commit 957107b

Browse files
authored
Use (string) $body instead of $body->getContents() for getting contents from StreamInterface. (#2871)
because method `getContents()` only returns the remaining contents in a string.
1 parent 59359db commit 957107b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Client.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function get($uri, $data = [], $headers = [])
6363
'query' => $data,
6464
]);
6565

66-
return $this->packer->unpack($response->getBody()->getContents());
66+
return $this->packer->unpack((string) $response->getBody());
6767
}
6868

6969
public function post($uri, $data = [], $headers = [])
@@ -73,7 +73,7 @@ public function post($uri, $data = [], $headers = [])
7373
'form_params' => $data,
7474
]);
7575

76-
return $this->packer->unpack($response->getBody()->getContents());
76+
return $this->packer->unpack((string) $response->getBody());
7777
}
7878

7979
public function put($uri, $data = [], $headers = [])
@@ -83,7 +83,7 @@ public function put($uri, $data = [], $headers = [])
8383
'form_params' => $data,
8484
]);
8585

86-
return $this->packer->unpack($response->getBody()->getContents());
86+
return $this->packer->unpack((string) $response->getBody());
8787
}
8888

8989
public function delete($uri, $data = [], $headers = [])
@@ -93,7 +93,7 @@ public function delete($uri, $data = [], $headers = [])
9393
'query' => $data,
9494
]);
9595

96-
return $this->packer->unpack($response->getBody()->getContents());
96+
return $this->packer->unpack((string) $response->getBody());
9797
}
9898

9999
public function json($uri, $data = [], $headers = [])
@@ -103,7 +103,7 @@ public function json($uri, $data = [], $headers = [])
103103
'headers' => $headers,
104104
'json' => $data,
105105
]);
106-
return $this->packer->unpack($response->getBody()->getContents());
106+
return $this->packer->unpack((string) $response->getBody());
107107
}
108108

109109
public function file($uri, $data = [], $headers = [])
@@ -129,7 +129,7 @@ public function file($uri, $data = [], $headers = [])
129129
'multipart' => $multipart,
130130
]);
131131

132-
return $this->packer->unpack($response->getBody()->getContents());
132+
return $this->packer->unpack((string) $response->getBody());
133133
}
134134

135135
public function request(string $method, string $path, array $options = [])

src/HttpClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function get($uri, $data = [], $headers = [])
5757
'headers' => $headers,
5858
'query' => $data,
5959
]);
60-
return $this->packer->unpack($response->getBody()->getContents());
60+
return $this->packer->unpack((string) $response->getBody());
6161
}
6262

6363
public function post($uri, $data = [], $headers = [])
@@ -67,7 +67,7 @@ public function post($uri, $data = [], $headers = [])
6767
'form_params' => $data,
6868
]);
6969

70-
return $this->packer->unpack($response->getBody()->getContents());
70+
return $this->packer->unpack((string) $response->getBody());
7171
}
7272

7373
public function json($uri, $data = [], $headers = [])
@@ -78,7 +78,7 @@ public function json($uri, $data = [], $headers = [])
7878
'headers' => $headers,
7979
]);
8080

81-
return $this->packer->unpack($response->getBody()->getContents());
81+
return $this->packer->unpack((string) $response->getBody());
8282
}
8383

8484
public function file($uri, $data = [], $headers = [])
@@ -104,6 +104,6 @@ public function file($uri, $data = [], $headers = [])
104104
'multipart' => $multipart,
105105
]);
106106

107-
return $this->packer->unpack($response->getBody()->getContents());
107+
return $this->packer->unpack((string) $response->getBody());
108108
}
109109
}

0 commit comments

Comments
 (0)