diff --git a/src/Http/Http.php b/src/Http/Http.php index d760260..d0666dd 100644 --- a/src/Http/Http.php +++ b/src/Http/Http.php @@ -17,7 +17,7 @@ class Http implements HttpContract { - public static function packRequest(string $method, string|Stringable $uri, array $headers = [], string|Stringable $body = '', string $protocolVersion = HttpContract::DEFAULT_PROTOCOL_VERSION): string + public static function packRequest(string $method, string|Stringable $path, array $headers = [], string|Stringable $body = '', string $protocolVersion = HttpContract::DEFAULT_PROTOCOL_VERSION): string { $headerString = ''; foreach ($headers as $key => $values) { @@ -29,7 +29,7 @@ public static function packRequest(string $method, string|Stringable $uri, array return sprintf( "%s %s HTTP/%s\r\n%s\r\n%s", $method, - $uri, + $path, $protocolVersion, $headerString, $body diff --git a/tests/Cases/HttpTest.php b/tests/Cases/HttpTest.php index 37a16c5..309e1bd 100644 --- a/tests/Cases/HttpTest.php +++ b/tests/Cases/HttpTest.php @@ -24,19 +24,13 @@ public function testHttpPackRequest() { $data = Http::packRequest('GET', '/', ['Content-Type' => 'application/json'], 'Hello World'); - $this->assertSame("GET / HTTP/1.1\r -Content-Type: application/json\r -\r -Hello World", $data); + $this->assertSame("GET / HTTP/1.1\r\nContent-Type: application/json\r\n\r\nHello World", $data); } public function testHttpPackResponse() { $data = Http::packResponse(200, 'OK', ['Content-Type' => 'application/json'], 'Hello World'); - $this->assertSame("HTTP/1.1 200 OK\r -Content-Type: application/json\r -\r -Hello World", $data); + $this->assertSame("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\nHello World", $data); } }