diff --git a/README.md b/README.md index af2fada9..92877f5a 100644 --- a/README.md +++ b/README.md @@ -52,16 +52,12 @@ Event-driven, streaming plaintext HTTP and secure HTTPS server for [ReactPHP](ht * [delete()](#delete) * [request()](#request) * [requestStreaming()](#requeststreaming) - * [~~submit()~~](#submit) - * [~~send()~~](#send) * [withTimeout()](#withtimeout) * [withFollowRedirects()](#withfollowredirects) * [withRejectErrorResponse()](#withrejecterrorresponse) * [withBase()](#withbase) * [withProtocolVersion()](#withprotocolversion) * [withResponseBuffer()](#withresponsebuffer) - * [~~withOptions()~~](#withoptions) - * [~~withoutBase()~~](#withoutbase) * [React\Http\Middleware](#reacthttpmiddleware) * [StreamingRequestMiddleware](#streamingrequestmiddleware) * [LimitConcurrentRequestsMiddleware](#limitconcurrentrequestsmiddleware) @@ -69,7 +65,6 @@ Event-driven, streaming plaintext HTTP and secure HTTPS server for [ReactPHP](ht * [RequestBodyParserMiddleware](#requestbodyparsermiddleware) * [ResponseInterface](#responseinterface) * [RequestInterface](#requestinterface) - * [UriInterface](#uriinterface) * [ResponseException](#responseexception) * [Install](#install) * [Tests](#tests) @@ -118,8 +113,6 @@ See also the [examples](examples). ### Request methods - - Most importantly, this project provides a [`Browser`](#browser) object that offers several methods that resemble the HTTP protocol methods: @@ -450,8 +443,6 @@ more details. ### Streaming response - - All of the above examples assume you want to store the whole response body in memory. This is easy to get started and works reasonably well for smaller responses. @@ -558,10 +549,6 @@ $stream->on('data', function ($data) { See also the [`requestStreaming()`](#requeststreaming) method for more details. -> Legacy info: Legacy versions prior to v2.9.0 used the legacy - [`streaming` option](#withoptions). This option is now deprecated but otherwise - continues to show the exact same behavior. - ### Streaming request Besides streaming the response body, you can also stream the request body. @@ -1105,8 +1092,6 @@ header or when using `Transfer-Encoding: chunked` for HTTP/1.1 requests. #### Streaming incoming request - - If you're using the advanced [`StreamingRequestMiddleware`](#streamingrequestmiddleware), the request object will be processed once the request headers have been received. This means that this happens irrespective of (i.e. *before*) receiving the @@ -1413,8 +1398,6 @@ If a promise is resolved after the client closes, it will simply be ignored. #### Streaming outgoing response - - The `Response` class in this project supports to add an instance which implements the [ReactPHP ReadableStreamInterface](https://github.com/reactphp/stream#readablestreaminterface) for the response body. @@ -1859,7 +1842,7 @@ $browser = new React\Http\Browser($loop, $connector); #### get() -The `get(string|UriInterface $url, array $headers = array()): PromiseInterface` method can be used to +The `get(string $url, array $headers = array()): PromiseInterface` method can be used to send an HTTP GET request. ```php @@ -1870,13 +1853,9 @@ $browser->get($url)->then(function (Psr\Http\Message\ResponseInterface $response See also [example 01](examples/01-google.php). -> For BC reasons, this method accepts the `$url` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - #### post() -The `post(string|UriInterface $url, array $headers = array(), string|ReadableStreamInterface $contents = ''): PromiseInterface` method can be used to +The `post(string $url, array $headers = array(), string|ReadableStreamInterface $contents = ''): PromiseInterface` method can be used to send an HTTP POST request. ```php @@ -1925,13 +1904,9 @@ $loop->addTimer(1.0, function () use ($body) { $browser->post($url, array('Content-Length' => '11'), $body); ``` -> For BC reasons, this method accepts the `$url` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - #### head() -The `head(string|UriInterface $url, array $headers = array()): PromiseInterface` method can be used to +The `head(string $url, array $headers = array()): PromiseInterface` method can be used to send an HTTP HEAD request. ```php @@ -1940,13 +1915,9 @@ $browser->head($url)->then(function (Psr\Http\Message\ResponseInterface $respons }); ``` -> For BC reasons, this method accepts the `$url` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - #### patch() -The `patch(string|UriInterface $url, array $headers = array(), string|ReadableStreamInterface $contents = ''): PromiseInterface` method can be used to +The `patch(string $url, array $headers = array(), string|ReadableStreamInterface $contents = ''): PromiseInterface` method can be used to send an HTTP PATCH request. ```php @@ -1976,13 +1947,9 @@ $loop->addTimer(1.0, function () use ($body) { $browser->patch($url, array('Content-Length' => '11'), $body); ``` -> For BC reasons, this method accepts the `$url` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - #### put() -The `put(string|UriInterface $url, array $headers = array()): PromiseInterface` method can be used to +The `put(string $url, array $headers = array()): PromiseInterface` method can be used to send an HTTP PUT request. ```php @@ -2014,13 +1981,9 @@ $loop->addTimer(1.0, function () use ($body) { $browser->put($url, array('Content-Length' => '11'), $body); ``` -> For BC reasons, this method accepts the `$url` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - #### delete() -The `delete(string|UriInterface $url, array $headers = array()): PromiseInterface` method can be used to +The `delete(string $url, array $headers = array()): PromiseInterface` method can be used to send an HTTP DELETE request. ```php @@ -2029,10 +1992,6 @@ $browser->delete($url)->then(function (Psr\Http\Message\ResponseInterface $respo }); ``` -> For BC reasons, this method accepts the `$url` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - #### request() The `request(string $method, string $url, array $headers = array(), string|ReadableStreamInterface $body = ''): PromiseInterface` method can be used to @@ -2070,12 +2029,6 @@ $loop->addTimer(1.0, function () use ($body) { $browser->request('POST', $url, array('Content-Length' => '11'), $body); ``` -> Note that this method is available as of v2.9.0 and always buffers the - response body before resolving. - It does not respect the deprecated [`streaming` option](#withoptions). - If you want to stream the response body, you can use the - [`requestStreaming()`](#requeststreaming) method instead. - #### requestStreaming() The `requestStreaming(string $method, string $url, array $headers = array(), string|ReadableStreamInterface $body = ''): PromiseInterface` method can be used to @@ -2138,55 +2091,6 @@ $loop->addTimer(1.0, function () use ($body) { $browser->requestStreaming('POST', $url, array('Content-Length' => '11'), $body); ``` -> Note that this method is available as of v2.9.0 and always resolves the - response without buffering the response body. - It does not respect the deprecated [`streaming` option](#withoptions). - If you want to buffer the response body, use can use the - [`request()`](#request) method instead. - -#### ~~submit()~~ - -> Deprecated since v2.9.0, see [`post()`](#post) instead. - -The deprecated `submit(string|UriInterface $url, array $fields, array $headers = array(), string $method = 'POST'): PromiseInterface` method can be used to -submit an array of field values similar to submitting a form (`application/x-www-form-urlencoded`). - -```php -// deprecated: see post() instead -$browser->submit($url, array('user' => 'test', 'password' => 'secret')); -``` - -> For BC reasons, this method accepts the `$url` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - -#### ~~send()~~ - -> Deprecated since v2.9.0, see [`request()`](#request) instead. - -The deprecated `send(RequestInterface $request): PromiseInterface` method can be used to -send an arbitrary instance implementing the [`RequestInterface`](#requestinterface) (PSR-7). - -The preferred way to send an HTTP request is by using the above -[request methods](#request-methods), for example the [`get()`](#get) -method to send an HTTP `GET` request. - -As an alternative, if you want to use a custom HTTP request method, you -can use this method: - -```php -$request = new Request('OPTIONS', $url); - -// deprecated: see request() instead -$browser->send($request)->then(…); -``` - -This method will automatically add a matching `Content-Length` request -header if the size of the outgoing request body is known and non-empty. -For an empty request body, if will only include a `Content-Length: 0` -request header if the request method usually expects a request body (only -applies to `POST`, `PUT` and `PATCH`). - #### withTimeout() The `withTimeout(bool|number $timeout): Browser` method can be used to @@ -2313,7 +2217,7 @@ given setting applied. #### withBase() -The `withBase(string|null|UriInterface $baseUrl): Browser` method can be used to +The `withBase(string|null $baseUrl): Browser` method can be used to change the base URL used to resolve relative URLs to. If you configure a base URL, any requests to relative URLs will be @@ -2346,14 +2250,6 @@ This method will throw an `InvalidArgumentException` if the given Notice that the [`Browser`](#browser) is an immutable object, i.e. the `withBase()` method actually returns a *new* [`Browser`](#browser) instance with the given base URL applied. -> For BC reasons, this method accepts the `$baseUrl` as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - -> Changelog: As of v2.9.0 this method accepts a `null` value to reset the - base URL. Earlier versions had to use the deprecated `withoutBase()` - method to reset the base URL. - #### withProtocolVersion() The `withProtocolVersion(string $protocolVersion): Browser` method can be used to @@ -2415,54 +2311,6 @@ Notice that the [`Browser`](#browser) is an immutable object, i.e. this method actually returns a *new* [`Browser`](#browser) instance with the given setting applied. -#### ~~withOptions()~~ - -> Deprecated since v2.9.0, see [`withTimeout()`](#withtimeout), [`withFollowRedirects()`](#withfollowredirects) - and [`withRejectErrorResponse()`](#withrejecterrorresponse) instead. - -The deprecated `withOptions(array $options): Browser` method can be used to -change the options to use: - -The [`Browser`](#browser) class exposes several options for the handling of -HTTP transactions. These options resemble some of PHP's -[HTTP context options](https://www.php.net/manual/en/context.http.php) and -can be controlled via the following API (and their defaults): - -```php -// deprecated -$newBrowser = $browser->withOptions(array( - 'timeout' => null, // see withTimeout() instead - 'followRedirects' => true, // see withFollowRedirects() instead - 'maxRedirects' => 10, // see withFollowRedirects() instead - 'obeySuccessCode' => true, // see withRejectErrorResponse() instead - 'streaming' => false, // deprecated, see requestStreaming() instead -)); -``` - -See also [timeouts](#timeouts), [redirects](#redirects) and -[streaming](#streaming-response) for more details. - -Notice that the [`Browser`](#browser) is an immutable object, i.e. this -method actually returns a *new* [`Browser`](#browser) instance with the -options applied. - -#### ~~withoutBase()~~ - -> Deprecated since v2.9.0, see [`withBase()`](#withbase) instead. - -The deprecated `withoutBase(): Browser` method can be used to -remove the base URL. - -```php -// deprecated: see withBase() instead -$newBrowser = $browser->withoutBase(); -``` - -Notice that the [`Browser`](#browser) is an immutable object, i.e. the `withoutBase()` method -actually returns a *new* [`Browser`](#browser) instance without any base URL applied. - -See also [`withBase()`](#withbase). - ### React\Http\Middleware #### StreamingRequestMiddleware @@ -2769,18 +2617,6 @@ This is a standard interface defined in which in turn extends the [`MessageInterface` definition](https://www.php-fig.org/psr/psr-7/#3-1-psr-http-message-messageinterface). -### UriInterface - -The `Psr\Http\Message\UriInterface` represents an absolute or relative URI (aka URL). - -This is a standard interface defined in -[PSR-7: HTTP message interfaces](https://www.php-fig.org/psr/psr-7/), see its -[`UriInterface` definition](https://www.php-fig.org/psr/psr-7/#3-5-psr-http-message-uriinterface). - -> For BC reasons, the request methods accept the URL as either a `string` - value or as an `UriInterface`. It's recommended to explicitly cast any - objects implementing `UriInterface` to `string`. - ### ResponseException The `ResponseException` is an `Exception` sub-class that will be used to reject diff --git a/src/Browser.php b/src/Browser.php index 70e875a2..38479c86 100644 --- a/src/Browser.php +++ b/src/Browser.php @@ -75,12 +75,8 @@ public function __construct(LoopInterface $loop, ConnectorInterface $connector = * * See also [example 01](../examples/01-google.php). * - * > For BC reasons, this method accepts the `$url` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * @param string|UriInterface $url URL for the request. - * @param array $headers + * @param string $url URL for the request. + * @param array $headers * @return PromiseInterface */ public function get($url, array $headers = array()) @@ -137,11 +133,7 @@ public function get($url, array $headers = array()) * $browser->post($url, array('Content-Length' => '11'), $body); * ``` * - * > For BC reasons, this method accepts the `$url` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * @param string|UriInterface $url URL for the request. + * @param string $url URL for the request. * @param array $headers * @param string|ReadableStreamInterface $contents * @return PromiseInterface @@ -160,12 +152,8 @@ public function post($url, array $headers = array(), $contents = '') * }); * ``` * - * > For BC reasons, this method accepts the `$url` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * @param string|UriInterface $url URL for the request. - * @param array $headers + * @param string $url URL for the request. + * @param array $headers * @return PromiseInterface */ public function head($url, array $headers = array()) @@ -203,11 +191,7 @@ public function head($url, array $headers = array()) * $browser->patch($url, array('Content-Length' => '11'), $body); * ``` * - * > For BC reasons, this method accepts the `$url` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * @param string|UriInterface $url URL for the request. + * @param string $url URL for the request. * @param array $headers * @param string|ReadableStreamInterface $contents * @return PromiseInterface @@ -249,11 +233,7 @@ public function patch($url, array $headers = array(), $contents = '') * $browser->put($url, array('Content-Length' => '11'), $body); * ``` * - * > For BC reasons, this method accepts the `$url` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * @param string|UriInterface $url URL for the request. + * @param string $url URL for the request. * @param array $headers * @param string|ReadableStreamInterface $contents * @return PromiseInterface @@ -272,11 +252,7 @@ public function put($url, array $headers = array(), $contents = '') * }); * ``` * - * > For BC reasons, this method accepts the `$url` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * @param string|UriInterface $url URL for the request. + * @param string $url URL for the request. * @param array $headers * @param string|ReadableStreamInterface $contents * @return PromiseInterface @@ -321,18 +297,11 @@ public function delete($url, array $headers = array(), $contents = '') * $browser->request('POST', $url, array('Content-Length' => '11'), $body); * ``` * - * > Note that this method is available as of v2.9.0 and always buffers the - * response body before resolving. - * It does not respect the deprecated [`streaming` option](#withoptions). - * If you want to stream the response body, you can use the - * [`requestStreaming()`](#requeststreaming) method instead. - * * @param string $method HTTP request method, e.g. GET/HEAD/POST etc. * @param string $url URL for the request * @param array $headers Additional request headers * @param string|ReadableStreamInterface $body HTTP request body contents * @return PromiseInterface - * @since 2.9.0 */ public function request($method, $url, array $headers = array(), $body = '') { @@ -399,93 +368,17 @@ public function request($method, $url, array $headers = array(), $body = '') * $browser->requestStreaming('POST', $url, array('Content-Length' => '11'), $body); * ``` * - * > Note that this method is available as of v2.9.0 and always resolves the - * response without buffering the response body. - * It does not respect the deprecated [`streaming` option](#withoptions). - * If you want to buffer the response body, use can use the - * [`request()`](#request) method instead. - * * @param string $method HTTP request method, e.g. GET/HEAD/POST etc. * @param string $url URL for the request * @param array $headers Additional request headers * @param string|ReadableStreamInterface $body HTTP request body contents * @return PromiseInterface - * @since 2.9.0 */ public function requestStreaming($method, $url, $headers = array(), $contents = '') { return $this->withOptions(array('streaming' => true))->requestMayBeStreaming($method, $url, $headers, $contents); } - /** - * [Deprecated] Submits an array of field values similar to submitting a form (`application/x-www-form-urlencoded`). - * - * ```php - * // deprecated: see post() instead - * $browser->submit($url, array('user' => 'test', 'password' => 'secret')); - * ``` - * - * This method will automatically add a matching `Content-Length` request - * header for the encoded length of the given `$fields`. - * - * > For BC reasons, this method accepts the `$url` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * @param string|UriInterface $url URL for the request. - * @param array $fields - * @param array $headers - * @param string $method - * @return PromiseInterface - * @deprecated 2.9.0 See self::post() instead. - * @see self::post() - */ - public function submit($url, array $fields, $headers = array(), $method = 'POST') - { - $headers['Content-Type'] = 'application/x-www-form-urlencoded'; - $contents = http_build_query($fields); - - return $this->requestMayBeStreaming($method, $url, $headers, $contents); - } - - /** - * [Deprecated] Sends an arbitrary instance implementing the [`RequestInterface`](#requestinterface) (PSR-7). - * - * The preferred way to send an HTTP request is by using the above - * [request methods](#request-methods), for example the [`get()`](#get) - * method to send an HTTP `GET` request. - * - * As an alternative, if you want to use a custom HTTP request method, you - * can use this method: - * - * ```php - * $request = new Request('OPTIONS', $url); - * - * // deprecated: see request() instead - * $browser->send($request)->then(…); - * ``` - * - * This method will automatically add a matching `Content-Length` request - * header if the size of the outgoing request body is known and non-empty. - * For an empty request body, if will only include a `Content-Length: 0` - * request header if the request method usually expects a request body (only - * applies to `POST`, `PUT` and `PATCH`). - * - * @param RequestInterface $request - * @return PromiseInterface - * @deprecated 2.9.0 See self::request() instead. - * @see self::request() - */ - public function send(RequestInterface $request) - { - if ($this->baseUrl !== null) { - // ensure we're actually below the base URL - $request = $request->withUri($this->messageFactory->expandBase($request->getUri(), $this->baseUrl)); - } - - return $this->transaction->send($request); - } - /** * Changes the maximum timeout used for waiting for pending requests. * @@ -676,15 +569,7 @@ public function withRejectErrorResponse($obeySuccessCode) * Notice that the [`Browser`](#browser) is an immutable object, i.e. the `withBase()` method * actually returns a *new* [`Browser`](#browser) instance with the given base URL applied. * - * > For BC reasons, this method accepts the `$baseUrl` as either a `string` - * value or as an `UriInterface`. It's recommended to explicitly cast any - * objects implementing `UriInterface` to `string`. - * - * > Changelog: As of v2.9.0 this method accepts a `null` value to reset the - * base URL. Earlier versions had to use the deprecated `withoutBase()` - * method to reset the base URL. - * - * @param string|null|UriInterface $baseUrl absolute base URL + * @param string|null $baseUrl absolute base URL * @return self * @throws InvalidArgumentException if the given $baseUrl is not a valid absolute URL * @see self::withoutBase() @@ -730,7 +615,6 @@ public function withBase($baseUrl) * @param string $protocolVersion HTTP protocol version to use, must be one of "1.1" or "1.0" * @return self * @throws InvalidArgumentException - * @since 2.8.0 */ public function withProtocolVersion($protocolVersion) { @@ -791,7 +675,7 @@ public function withResponseBuffer($maximumSize) } /** - * [Deprecated] Changes the [options](#options) to use: + * Changes the [options](#options) to use: * * The [`Browser`](#browser) class exposes several options for the handling of * HTTP transactions. These options resemble some of PHP's @@ -818,12 +702,11 @@ public function withResponseBuffer($maximumSize) * * @param array $options * @return self - * @deprecated 2.9.0 See self::withTimeout(), self::withFollowRedirects() and self::withRejectErrorResponse() instead. * @see self::withTimeout() * @see self::withFollowRedirects() * @see self::withRejectErrorResponse() */ - public function withOptions(array $options) + private function withOptions(array $options) { $browser = clone $this; $browser->transaction = $this->transaction->withOptions($options); @@ -831,28 +714,6 @@ public function withOptions(array $options) return $browser; } - /** - * [Deprecated] Removes the base URL. - * - * ```php - * // deprecated: see withBase() instead - * $newBrowser = $browser->withoutBase(); - * ``` - * - * Notice that the [`Browser`](#browser) is an immutable object, i.e. the `withoutBase()` method - * actually returns a *new* [`Browser`](#browser) instance without any base URL applied. - * - * See also [`withBase()`](#withbase). - * - * @return self - * @deprecated 2.9.0 See self::withBase() instead. - * @see self::withBase() - */ - public function withoutBase() - { - return $this->withBase(null); - } - /** * @param string $method * @param string|UriInterface $url @@ -862,6 +723,12 @@ public function withoutBase() */ private function requestMayBeStreaming($method, $url, array $headers = array(), $contents = '') { - return $this->send($this->messageFactory->request($method, $url, $headers, $contents, $this->protocolVersion)); + $request = $this->messageFactory->request($method, $url, $headers, $contents, $this->protocolVersion); + if ($this->baseUrl !== null) { + // ensure we're actually below the base URL + $request = $request->withUri($this->messageFactory->expandBase($request->getUri(), $this->baseUrl)); + } + + return $this->transaction->send($request); } } diff --git a/tests/BrowserTest.php b/tests/BrowserTest.php index 56a28303..88ef107e 100644 --- a/tests/BrowserTest.php +++ b/tests/BrowserTest.php @@ -120,19 +120,6 @@ public function testRequestStreamingGetSendsGetRequestWithStreamingExplicitlyEna $this->browser->requestStreaming('GET', 'http://example.com/'); } - public function testSubmitSendsPostRequest() - { - $that = $this; - $this->sender->expects($this->once())->method('send')->with($this->callback(function (RequestInterface $request) use ($that) { - $that->assertEquals('POST', $request->getMethod()); - $that->assertEquals('application/x-www-form-urlencoded', $request->getHeaderLine('Content-Type')); - $that->assertEquals('', (string)$request->getBody()); - return true; - }))->willReturn(new Promise(function () { })); - - $this->browser->submit('http://example.com/', array()); - } - public function testWithTimeoutTrueSetsDefaultTimeoutOption() { $this->sender->expects($this->once())->method('withOptions')->with(array('timeout' => null))->willReturnSelf(); @@ -356,7 +343,7 @@ public function testWithBaseUrlInvalidSchemeFails() public function testWithoutBaseFollowedByGetRequestTriesToSendIncompleteRequestUrl() { - $this->browser = $this->browser->withBase('http://example.com')->withoutBase(); + $this->browser = $this->browser->withBase('http://example.com')->withBase(null); $that = $this; $this->sender->expects($this->once())->method('send')->with($this->callback(function (RequestInterface $request) use ($that) { @@ -380,19 +367,6 @@ public function testWithProtocolVersionFollowedByGetRequestSendsRequestWithProto $this->browser->get('http://example.com/'); } - public function testWithProtocolVersionFollowedBySubmitRequestSendsRequestWithProtocolVersion() - { - $this->browser = $this->browser->withProtocolVersion('1.0'); - - $that = $this; - $this->sender->expects($this->once())->method('send')->with($this->callback(function (RequestInterface $request) use ($that) { - $that->assertEquals('1.0', $request->getProtocolVersion()); - return true; - }))->willReturn(new Promise(function () { })); - - $this->browser->submit('http://example.com/', array()); - } - public function testWithProtocolVersionInvalidThrows() { $this->setExpectedException('InvalidArgumentException'); diff --git a/tests/FunctionalBrowserTest.php b/tests/FunctionalBrowserTest.php index 16293fbb..c4bbe523 100644 --- a/tests/FunctionalBrowserTest.php +++ b/tests/FunctionalBrowserTest.php @@ -180,9 +180,9 @@ public function testCancelGetRequestWillRejectRequest() Block\await($promise, $this->loop); } - public function testCancelSendWithPromiseFollowerWillRejectRequest() + public function testCancelRequestWithPromiseFollowerWillRejectRequest() { - $promise = $this->browser->send(new Request('GET', $this->base . 'get'))->then(function () { + $promise = $this->browser->request('GET', $this->base . 'get')->then(function () { var_dump('noop'); }); $promise->cancel(); @@ -455,7 +455,7 @@ public function testReceiveStreamUntilConnectionsEndsForHttp10() public function testReceiveStreamChunkedForHttp11() { - $response = Block\await($this->browser->send(new Request('GET', $this->base . 'stream/1', array(), null, '1.1')), $this->loop); + $response = Block\await($this->browser->request('GET', $this->base . 'stream/1'), $this->loop); $this->assertEquals('1.1', $response->getProtocolVersion()); @@ -600,15 +600,6 @@ public function testHeadRequestReceivesResponseWithEmptyBodyButWithContentLength $this->assertEquals('5', $response->getHeaderLine('Content-Length')); } - public function testRequestGetReceivesBufferedResponseEvenWhenStreamingOptionHasBeenTurnedOn() - { - $response = Block\await( - $this->browser->withOptions(array('streaming' => true))->request('GET', $this->base . 'get'), - $this->loop - ); - $this->assertEquals('hello', (string)$response->getBody()); - } - public function testRequestStreamingGetReceivesStreamingResponseBody() { $buffer = Block\await( @@ -621,16 +612,6 @@ public function testRequestStreamingGetReceivesStreamingResponseBody() $this->assertEquals('hello', $buffer); } - public function testRequestStreamingGetReceivesStreamingResponseEvenWhenStreamingOptionHasBeenTurnedOff() - { - $response = Block\await( - $this->browser->withOptions(array('streaming' => false))->requestStreaming('GET', $this->base . 'get'), - $this->loop - ); - $this->assertInstanceOf('React\Stream\ReadableStreamInterface', $response->getBody()); - $this->assertEquals('', (string)$response->getBody()); - } - public function testRequestStreamingGetReceivesStreamingResponseBodyEvenWhenResponseBufferExceeded() { $buffer = Block\await(