Fix possible response truncation in HTTPRequest on Windows
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 23 Jul 2020 11:59:01 +0000 (13:59 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 23 Jul 2020 11:59:01 +0000 (13:59 +0200)
wcfsetup/install/files/lib/util/HTTPRequest.class.php

index 27c84c7a290ded3adfe89962e71b199908b6b998..5fb4cabaf8ee41fb29b17037cde34dc47c732a75 100644 (file)
@@ -190,7 +190,10 @@ final class HTTPRequest {
                $request = new Request($this->options['method'], $this->url, $headers, $this->body);
                
                try {
-                       $this->response = $client->send($request);
+                       $this->response = $client->send($request, [
+                               // https://github.com/guzzle/guzzle/issues/2735
+                               'sink' => fopen("php://temp", "w+"),
+                       ]);
                }
                catch (TooManyRedirectsException $e) {
                        throw new HTTPException(
@@ -269,7 +272,7 @@ final class HTTPRequest {
                if ($this->replyBody === null) {
                        $bodyLength = 0;
                        while (!$this->response->getBody()->eof()) {
-                               $toRead = 1024;
+                               $toRead = 8192;
                                if (isset($this->options['maxLength'])) {
                                        $toRead = min($toRead, $this->options['maxLength'] - $bodyLength);
                                }