PK ?VCif f LICENSEnu W+A The MIT License (MIT) Copyright (c) 2013 Daniel Lowrey, Levi Morrison Copyright (c) 2014-2019 amphp Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK ?Vh composer.jsonnu W+A { "name": "amphp/http-client", "homepage": "https://github.com/amphp/http-client", "description": "Asynchronous parallel HTTP/2 and HTTP/1.1 client built on the Amp concurrency framework", "keywords": [ "http", "rest", "client", "parallel", "async", "non-blocking" ], "license": "MIT", "authors": [ { "name": "Daniel Lowrey", "email": "rdlowrey@gmail.com" }, { "name": "Niklas Keller", "email": "me@kelunik.com" }, { "name": "Aaron Piotrowski", "email": "aaron@trowski.com" } ], "require": { "php": ">=7.2", "amphp/amp": "^2.4", "amphp/byte-stream": "^1.6", "amphp/hpack": "^2", "amphp/http": "^1.3", "amphp/socket": "^1", "amphp/sync": "^1.3", "league/uri": "^6", "psr/http-message": "^1" }, "require-dev": { "ext-json": "*", "amphp/file": "^1 || ^0.3 || ^0.2", "amphp/phpunit-util": "^1.1", "amphp/php-cs-fixer-config": "dev-master", "phpunit/phpunit": "^7 || ^8", "amphp/http-server": "^2-rc3" }, "suggest": { "ext-zlib": "*", "ext-json": "*", "amphp/file": "Required for file request bodies" }, "autoload": { "psr-4": { "Amp\\Http\\Client\\": "src" } }, "autoload-dev": { "psr-4": { "Amp\\Http\\Client\\": "test" } }, "conflict": { "amphp/file": "<0.2 || >=2" }, "scripts": { "check": [ "@cs", "@test" ], "cs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff --dry-run", "cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff", "test": "@php -dzend.assertions=1 -dassert.exception=1 ./vendor/bin/phpunit --coverage-text" } } PK ?VN_ CHANGELOG.mdnu W+A # Changelog ## 3.0.14 - Fixed timeout token leak (#157) ## 3.0.13 - Bumped `amphp/file` to `^0.2 || ^0.3`. ## 3.0.12 - Apply timeouts correctly during connection and TLS handshakes. Previously these could hang indefinitely. See #145. ## 3.0.11 - Fixed issues with responses without `content-length` and without `transfer-encoding: chunked`. - Revert fix for v3.0.10, as this has been properly fixed in `amphp/byte-stream`. - Catch `ConnectException` from `amphp/socket` and throw `SocketException` instead. The exception was previously leaked, but undocumented and unexpected. ## 3.0.10 - Fixed issue with unknown socket on shutdown due to unpredictable `__destruct()` call order. ## 3.0.9 - Lazily parse captured TLS certificates. This improves performance and memory usage. Additionally, `openssl_x509_parse` currently leaks memory. This fix ensures it leaks only if explicitly requested (until the PHP bug is fixed). See https://bugs.php.net/bug.php?id=75363. - Small performance improvements for connections not using a proxy. ## 3.0.8 - Fixed null pointer access in response handling completely breaking the client. ## 3.0.7 [ borked ] - Clean references correctly, so unused bodies aren't consumed and the connection is closed. ## 3.0.6 - Allow empty content type for multipart form fields. - Fail aborted requests correctly. - Apply transfer timeouts correctly (was previously a header timeout only). - Check for incomplete response bodies and error out in case of an incomplete body. - Close sockets if response body is not consumed instead of trying to silently consume it in the background, which might hang indefinitely (depending on the timeout). ## 3.0.5 - Fixed multipart body bounaries not ending in `\r\n`. ## 3.0.4 - Fixed GC issues if request bodies mismatches the specified content-length. ## 3.0.3 - Read the public suffix list only once instead of once per check. This was supposed to work previously, but failed to set the `$initialized` flag. ## 3.0.2 - Fixed issues with cookies when IDN support is not available. ## 3.0.1 - Enforce body size limit also for compressed responses. This is a protection measure against malicious servers as described [here](https://blog.haschek.at/2017/how-to-defend-your-website-with-zip-bombs.html). ## 3.0.0 - Upgrade to Amp v2. - Major refactoring for streamed response bodies. - Updated redirect policy to use a new `Request` if the host changes. PK ?VDX1 1 README.mdnu W+A
[![Build Status](https://img.shields.io/travis/amphp/http-client/master.svg?style=flat-square)](https://travis-ci.org/amphp/http-client) [![CoverageStatus](https://img.shields.io/coveralls/amphp/http-client/master.svg?style=flat-square)](https://coveralls.io/github/amphp/http-client?branch=master) ![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square) This package provides an asynchronous HTTP client for PHP based on [Amp](https://github.com/amphp/amp). Its API simplifies standards-compliant HTTP resource traversal and RESTful web service consumption without obscuring the underlying protocol. The library manually implements HTTP over TCP sockets; as such it has no dependency on `ext/curl`. ## Features - Supports HTTP/1 and HTTP/2 - [Requests concurrently by default](examples/concurrency/6-concurrent-requests.php) - [Pools persistent connections (keep-alive @ HTTP/1.1, multiplexing @ HTTP/2)](examples/pooling/10-connection-pooling.php) - [Transparently follows redirects](https://amphp.org/http-client/follow-redirects) - [Decodes compressed entity bodies (gzip, deflate)](examples/basic/12-gzip.php) - [Exposes headers and message data](examples/basic/1-get-request.php) - [Streams entity bodies for memory management with large transfers](examples/streaming/5-streaming-responses.php) - [Supports all standard and custom HTTP method verbs](https://amphp.org/http-client/requests#request-method) - [Simplifies HTTP form submissions](examples/basic/4-forms.php) - [Implements secure-by-default TLS (`https://`)](examples/basic/1-get-request.php) - [Supports cookies and sessions](https://github.com/amphp/http-client-cookies) - [Functions seamlessly behind HTTP proxies](https://github.com/amphp/http-tunnel) ## Installation This package can be installed as a [Composer](https://getcomposer.org/) dependency. ```bash composer require amphp/http-client ``` ## Documentation Documentation is bundled within this repository in the [`docs`](./docs) directory. ## Examples More extensive code examples reside in the [`examples`](./examples) directory. ## Versioning `amphp/http-client` follows the [semver](http://semver.org/) semantic versioning specification like all other `amphp` packages. ##### 4.x Under development. ##### [3.x](https://github.com/amphp/artax/tree/master) Use [`amphp/artax`](https://github.com/amphp/artax) as package name instead. ##### [2.x](https://github.com/amphp/artax/tree/2.x) No longer maintained. Use [`amphp/artax`](https://github.com/amphp/artax) as package name instead. ##### [1.x](https://github.com/amphp/artax/tree/1.x) No longer maintained. Use [`amphp/artax`](https://github.com/amphp/artax) as package name instead. ## Security If you discover any security related issues, please email [`me@kelunik.com`](mailto:me@kelunik.com) instead of using the issue tracker. ## License The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. PK ?VA src/MissingAttributeError.phpnu W+A hasAttribute(HarAttributes::STARTED_DATE_TIME)) { $request->setAttribute(HarAttributes::STARTED_DATE_TIME, new \DateTimeImmutable); } return $this->addTiming(HarAttributes::TIME_START, $request); } public function startDnsResolution(Request $request): Promise { return new Success; // not implemented } public function startConnectionCreation(Request $request): Promise { return $this->addTiming(HarAttributes::TIME_CONNECT, $request); } public function startTlsNegotiation(Request $request): Promise { return $this->addTiming(HarAttributes::TIME_SSL, $request); } public function startSendingRequest(Request $request, Stream $stream): Promise { $host = $stream->getRemoteAddress()->getHost(); if (\strrpos($host, ':')) { $host = '[' . $host . ']'; } $request->setAttribute(HarAttributes::SERVER_IP_ADDRESS, $host); return $this->addTiming(HarAttributes::TIME_SEND, $request); } public function completeSendingRequest(Request $request, Stream $stream): Promise { return $this->addTiming(HarAttributes::TIME_WAIT, $request); } public function startReceivingResponse(Request $request, Stream $stream): Promise { return $this->addTiming(HarAttributes::TIME_RECEIVE, $request); } public function completeReceivingResponse(Request $request, Stream $stream): Promise { return $this->addTiming(HarAttributes::TIME_COMPLETE, $request); } public function completeDnsResolution(Request $request): Promise { return new Success; // not implemented } public function completeConnectionCreation(Request $request): Promise { return new Success; // not implemented } public function completeTlsNegotiation(Request $request): Promise { return new Success; // not implemented } private function addTiming(string $key, Request $request): Promise { if (!$request->hasAttribute($key)) { $request->setAttribute($key, getCurrentTime()); } return new Success; } } PK ?VY'Ã src/NetworkInterceptor.phpnu W+A request(...)` resolved. * * A NetworkInterceptor MUST NOT short-circuit and MUST delegate to the `$stream` passed as third argument exactly * once. The only exception to this rule is throwing an exception, e.g. because the TLS settings used are * unacceptable. If you need short circuits, use an {@see ApplicationInterceptor} instead. * * @param Request $request * @param CancellationToken $cancellation * @param Stream $stream * * @return Promise