1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Update dependencies.

This commit is contained in:
Caleb Mazalevskis 2022-01-06 20:13:38 +08:00
parent 43c00721ca
commit feb9ac315b
No known key found for this signature in database
GPG key ID: 082E6BC1046FAB95
11243 changed files with 338413 additions and 11922 deletions

461
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -2,144 +2,95 @@
[![Build Status](https://travis-ci.org/razorpay/razorpay-php.svg?branch=master)](https://travis-ci.org/razorpay/razorpay-php) [![Latest Stable Version](https://poser.pugx.org/razorpay/razorpay/v/stable.svg)](https://packagist.org/packages/razorpay/razorpay) [![License](https://poser.pugx.org/razorpay/razorpay/license.svg)](https://packagist.org/packages/razorpay/razorpay)
Razorpay client PHP API. The Api follows the following practices:
Official PHP library for [Razorpay API](https://docs.razorpay.com/docs/payments).
- Namespaced under `Razorpay\Api`
- Call `$api->class->function()` to access the API
- API throws exceptions instead of returning errors
- Options are passed as an array instead of multiple arguments wherever possible
- All requests and responses are communicated over JSON
- A minimum of PHP 5.3 is required
Read up here for getting started and understanding the payment flow with Razorpay: <https://docs.razorpay.com/docs/getting-started>
# Installation
### Prerequisites
- A minimum of PHP 5.3 is required
- If your project uses composer, run the below command
## Installation
- If your project using composer, run the below command
```
composer require razorpay/razorpay:2.*
```
- If you are not using composer, download the latest release from [the releases section](https://github.com/razorpay/razorpay-php/releases).
- If you are not using composer, download the latest release from [the releases section](https://github.com/razorpay/razorpay-php/releases).
**You should download the `razorpay-php.zip` file**.
After that, include `Razorpay.php` in your application and you can use the API as usual.
# Usage
##Note:
This PHP library follows the following practices:
- Namespaced under `Razorpay\Api`
- API throws exceptions instead of returning errors
- Options are passed as an array instead of multiple arguments wherever possible
- All requests and responses are communicated over JSON
## Documentation
Documentation of Razorpay's API and their usage is available at <https://docs.razorpay.com>
## Basic Usage
Instantiate the razorpay php instance with `key_id` & `key_secret`. You can obtain the keys from the dashboard app ([https://dashboard.razorpay.com/#/app/keys](https://dashboard.razorpay.com/#/app/keys))
```php
use Razorpay\Api\Api;
$api = new Api($api_key, $api_secret);
// Orders
$order = $api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR')); // Creates order
$order = $api->order->fetch($orderId); // Returns a particular order
$orders = $api->order->all($options); // Returns array of order objects
$payments = $api->order->fetch($orderId)->payments(); // Returns array of payment objects against an order
// Payments
$payments = $api->payment->all($options); // Returns array of payment objects
$payment = $api->payment->fetch($id); // Returns a particular payment
$payment = $api->payment->fetch($id)->capture(array('amount'=>$amount)); // Captures a payment
// To get the payment details
echo $payment->amount;
echo $payment->currency;
// And so on for other attributes
// Refunds
$refund = $api->refund->create(array('payment_id' => $id)); // Creates refund for a payment
$refund = $api->refund->create(array('payment_id' => $id, 'amount'=>$refundAmount)); // Creates partial refund for a payment
$refund = $api->refund->fetch($refundId); // Returns a particular refund
// Cards
$card = $api->card->fetch($cardId); // Returns a particular card
// Customers
$customer = $api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com')); // Creates customer
$customer = $api->customer->fetch($customerId); // Returns a particular customer
$customer = $api->customer->edit(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com')); // Edits customer
// Tokens
$token = $api->customer->token()->fetch($tokenId); // Returns a particular token
$tokens = $api->customer->token()->all($options); // Returns array of token objects
$api->customer->token()->delete($tokenId); // Deletes a token
// Transfers
$transfer = $api->payment->fetch($paymentId)->transfer(array('transfers' => [ ['account' => $accountId, 'amount' => 100, 'currency' => 'INR']])); // Create transfer
$transfers = $api->transfer->all(); // Fetch all transfers
$transfers = $api->payment->fetch($paymentId)->transfers(); // Fetch all transfers created on a payment
$transfer = $api->transfer->fetch($transferId)->edit($options); // Edit a transfer
$reversal = $api->transfer->fetch($transferId)->reverse(); // Reverse a transfer
// Payment Links
$links = $api->invoice->all();
$link = $api->invoice->fetch('inv_00000000000001');
$link = $api->invoice->create(arary('type' => 'link', 'amount' => 500, 'description' => 'For XYZ purpose', 'customer' => array('email' => 'test@test.test')));
$link->cancel();
$link->notifyBy('sms');
// Invoices
$invoices = $api->invoice->all();
$invoice = $api->invoice->fetch('inv_00000000000001');
$invoice = $api->invoice->create($params); // Ref: razorpay.com/docs/invoices for request params example
$invoice = $invoice->edit($params);
$invoice->issue();
$invoice->notifyBy('email');
$invoice->cancel();
$invoice->delete();
// Virtual Accounts
$virtualAccount = $api->virtualAccount->create(array('receiver_types' => array('bank_account'), 'description' => 'First Virtual Account', 'notes' => array('receiver_key' => 'receiver_value')));
$virtualAccounts = $api->virtualAccount->all();
$virtualAccount = $api->virtualAccount->fetch('va_4xbQrmEoA5WJ0G');
$virtualAccount = $virtualAccount->close();
$payments = $virtualAccount->payments();
$bankTransfer = $api->payment->fetch('pay_8JpVEWsoNPKdQh')->bankTransfer();
// Bharat QR
$bharatQR = $api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code', 'amount_expected' => 100, 'notes' => array('receiver_key' => 'receiver_value'))); // Create Static QR
$bharatQR = $api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code', 'notes' => array('receiver_key' => 'receiver_value'))); // Create Dynamic QR
// Subscriptions
$plan = $api->plan->create(array('period' => 'weekly', 'interval' => 1, 'item' => array('name' => 'Test Weekly 1 plan', 'description' => 'Description for the weekly 1 plan', 'amount' => 600, 'currency' => 'INR')));
$plan = $api->plan->fetch('plan_7wAosPWtrkhqZw');
$plans = $api->plan->all();
$subscription = $api->subscription->create(array('plan_id' => 'plan_7wAosPWtrkhqZw', 'customer_notify' => 1, 'total_count' => 6, 'start_at' => 1495995837, 'addons' => array(array('item' => array('name' => 'Delivery charges', 'amount' => 30000, 'currency' => 'INR')))));
$subscription = $api->subscription->fetch('sub_82uBGfpFK47AlA');
$subscriptions = $api->subscription->all();
$subscription = $api->subscription->fetch('sub_82uBGfpFK47AlA')->cancel($options); //$options = ['cancel_at_cycle_end' => 1];
$addon = $api->subscription->fetch('sub_82uBGfpFK47AlA')->createAddon(array('item' => array('name' => 'Extra Chair', 'amount' => 30000, 'currency' => 'INR'), 'quantity' => 2));
$addon = $api->addon->fetch('ao_8nDvQYYGQI5o4H');
$addon = $api->addon->fetch('ao_8nDvQYYGQI5o4H')->delete();
// Settlements
$settlement = $api->settlement->fetch('setl_7IZKKI4Pnt2kEe');
$settlements = $api->settlement->all();
$reports = $api->settlement->reports(array('year' => 2018, 'month' => 2));
```
For further help, see our documentation on <https://docs.razorpay.com>.
The resources can be accessed via the `$api` object. All the methods invocations follows the following pattern
[composer-install]: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
```php
// $api->class->function() to access the API
//Example
$api->payment->fetch($paymentId);
```
## Supported Resources
- [Customer](documents/customer.md)
- [Token](documents/token.md)
- [Order](documents/order.md)
- [Payments](documents/payment.md)
- [Settlements](documents/settlement.md)
- [Refunds](documents/refund.md)
- [Invoice](documents/invoice.md)
- [Item](documents/item.md)
- [Subscriptions](documents/subscription.md)
- [Add-on](documents/addon.md)
- [Payment Links](documents/paymentLink.md)
- [Smart Collect](documents/virtualaccount.md)
- [Route](documents/transfer.md)
- [QR Code](documents/qrcode.md)
- [Emandate](documents/emandate.md)
- [Cards](documents/card.md)
- [Paper NACH](documents/papernach.md)
- [UPI](documents/upi.md)
- [Register Emandate and Charge First Payment Together](documents/registeremandate.md)
- [Register NACH and Charge First Payment Together](documents/registernach.md)
- [Payment Verification](documents/paymentVerfication.md)
## Developing
## Development
See the [doc.md](doc.md) file for getting started with development.
## License
The Razorpay PHP SDK is released under the MIT License. See [LICENSE](LICENSE) file for more details.
## Release
Steps to follow for a release:
0. Merge the branch with the new code to master.
1. Bump the Version in `src/Api.php`.
1. Rename Unreleased to the new tag in `CHANGELOG.md`
1. Add a new empty "Unreleased" section at the top of `CHANGELOG.md`
1. Fix links at bottom in `CHANGELOG.md`
1. Commit
1. Tag the release and push to GitHub
1. A release should automatically be created once the travis build passes. Edit the release to add some description.
0. Merge the branch with the new code to master.
1. Bump the Version in `src/Api.php`.
2. Rename Unreleased to the new tag in `CHANGELOG.md`
3. Add a new empty "Unreleased" section at the top of `CHANGELOG.md`
4. Fix links at bottom in `CHANGELOG.md`
5. Commit
6. Tag the release and push to GitHub
7. A release should automatically be created once the travis build passes. Edit the release to add some description.
## License
The Razorpay PHP SDK is released under the MIT License. See [LICENSE](LICENSE) file for more details.

View file

@ -3,7 +3,7 @@
// Include Requests only if not already defined
if (class_exists('Requests') === false)
{
require_once __DIR__.'/libs/Requests-1.7.0/library/Requests.php';
require_once __DIR__.'/libs/Requests-1.8.0/library/Requests.php';
}
try

View file

@ -24,7 +24,7 @@
"license": "MIT",
"require": {
"php": ">=5.3.0",
"rmccue/requests": "v1.7.0",
"rmccue/requests": "v1.8.0",
"ext-json": "*"
},
"require-dev": {

View file

@ -1,4 +0,0 @@
src_dir: library
coverage_clover: tests/clover.xml
json_path: tests/coveralls.json
service_name: travis-ci

View file

@ -1,6 +0,0 @@
# Ignore coverage report
tests/coverage/*
# Ignore composer related files
/composer.lock
/vendor

View file

@ -1,58 +0,0 @@
language: php
matrix:
fast_finish: true
include:
- php: 5.2
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
env: TEST_COVERAGE=1
- php: 7.0
- php: hhvm
# Use new container infrastructure
sudo: false
cache:
directories:
- $HOME/.cache/pip
- $HOME/.composer/cache
- vendor
install:
# Setup the test server
- phpenv local 5.5
- composer install --dev --no-interaction
- TESTPHPBIN=$(phpenv which php)
- phpenv local --unset
# Setup the proxy
- pip install --user mitmproxy~=0.15
before_script:
- PHPBIN=$TESTPHPBIN PORT=8080 vendor/bin/start.sh
- export REQUESTS_TEST_HOST_HTTP="localhost:8080"
# Work out of the tests directory
- cd tests
- PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9002 utils/proxy/start.sh
- PROXYBIN="$HOME/.local/bin/mitmdump" PORT=9003 AUTH="test:pass" utils/proxy/start.sh
- export REQUESTS_HTTP_PROXY="localhost:9002"
- export REQUESTS_HTTP_PROXY_AUTH="localhost:9003"
- export REQUESTS_HTTP_PROXY_AUTH_USER="test"
- export REQUESTS_HTTP_PROXY_AUTH_PASS="pass"
# Ensure the HTTPS test instance on Heroku is spun up
- curl -s -I http://requests-php-tests.herokuapp.com/ > /dev/null
script:
- phpunit --coverage-clover clover.xml
after_script:
- utils/proxy/stop.sh
- cd ..
- phpenv local 5.5
- PATH=$PATH vendor/bin/stop.sh
- test $TEST_COVERAGE && bash <(curl -s https://codecov.io/bash)
- phpenv local --unset

View file

@ -1,315 +0,0 @@
Changelog
=========
1.7.0
-----
- Add support for HHVM and PHP 7
Requests is now tested against both HHVM and PHP 7, and they are supported as
first-party platforms.
(props @rmccue, [#106][gh-106], [#176][gh-176])
- Transfer & connect timeouts, in seconds & milliseconds
cURL is unable to handle timeouts under a second in DNS lookups, so we round
those up to ensure 1-999ms isn't counted as an instant failure.
(props @ozh, @rmccue, [#97][gh-97], [#216][gh-216])
- Rework cookie handling to be more thorough.
Cookies are now restricted to the same-origin by default, expiration is checked.
(props @catharsisjelly, @rmccue, [#120][gh-120], [#124][gh-124], [#130][gh-130], [#132][gh-132], [#156][gh-156])
- Improve testing
Tests are now run locally to speed them up, as well as further general
improvements to the quality of the testing suite. There are now also
comprehensive proxy tests to ensure coverage there.
(props @rmccue, [#75][gh-75], [#107][gh-107], [#170][gh-170], [#177][gh-177], [#181][gh-181], [#183][gh-183], [#185][gh-185], [#196][gh-196], [#202][gh-202], [#203][gh-203])
- Support custom HTTP methods
Previously, custom HTTP methods were only supported on sockets; they are now
supported across all transports.
(props @ocean90, [#227][gh-227])
- Add byte limit option
(props @rmccue, [#172][gh-172])
- Support a Requests_Proxy_HTTP() instance for the proxy setting.
(props @ocean90, [#223][gh-223])
- Add progress hook
(props @rmccue, [#180][gh-180])
- Add a before_redirect hook to alter redirects
(props @rmccue, [#205][gh-205])
- Pass cURL info to after_request
(props @rmccue, [#206][gh-206])
- Remove explicit autoload in Composer installation instructions
(props @SlikNL, [#86][gh-86])
- Restrict CURLOPT_PROTOCOLS on `defined()` instead of `version_compare()`
(props @ozh, [#92][gh-92])
- Fix doc - typo in "Authentication"
(props @remik, [#99][gh-99])
- Contextually check for a valid transport
(props @ozh, [#101][gh-101])
- Follow relative redirects correctly
(props @ozh, [#103][gh-103])
- Use cURL's version_number
(props @mishan, [#104][gh-104])
- Removed duplicated option docs
(props @staabm, [#112][gh-112])
- code styling fixed
(props @imsaintx, [#113][gh-113])
- Fix IRI "normalization"
(props @ozh, [#128][gh-128])
- Mention two PHP extension dependencies in the README.
(props @orlitzky, [#136][gh-136])
- Ignore coverage report files
(props @ozh, [#148][gh-148])
- drop obsolete "return" after throw
(props @staabm, [#150][gh-150])
- Updated exception message to specify both http + https
(props @beutnagel, [#162][gh-162])
- Sets `stream_headers` method to public to allow calling it from other
places.
(props @adri, [#158][gh-158])
- Remove duplicated stream_get_meta_data call
(props @rmccue, [#179][gh-179])
- Transmits $errno from stream_socket_client in exception
(props @laurentmartelli, [#174][gh-174])
- Correct methods to use snake_case
(props @rmccue, [#184][gh-184])
- Improve code quality
(props @rmccue, [#186][gh-186])
- Update Build Status image
(props @rmccue, [#187][gh-187])
- Fix/Rationalize transports (v2)
(props @rmccue, [#188][gh-188])
- Surface cURL errors
(props @ifwe, [#194][gh-194])
- Fix for memleak and curl_close() never being called
(props @kwuerl, [#200][gh-200])
- addex how to install with composer
(props @royopa, [#164][gh-164])
- Uppercase the method to ensure compatibility
(props @rmccue, [#207][gh-207])
- Store default certificate path
(props @rmccue, [#210][gh-210])
- Force closing keep-alive connections on old cURL
(props @rmccue, [#211][gh-211])
- Docs: Updated HTTP links with HTTPS links where applicable
(props @ntwb, [#215][gh-215])
- Remove the executable bit
(props @ocean90, [#224][gh-224])
- Change more links to HTTPS
(props @rmccue, [#217][gh-217])
- Bail from cURL when either `curl_init()` OR `curl_exec()` are unavailable
(props @dd32, [#230][gh-230])
- Disable OpenSSL's internal peer_name checking when `verifyname` is disabled.
(props @dd32, [#239][gh-239])
- Only include the port number in the `Host` header when it differs from
default
(props @dd32, [#238][gh-238])
- Respect port if specified for HTTPS connections
(props @dd32, [#237][gh-237])
- Allow paths starting with a double-slash
(props @rmccue, [#240][gh-240])
- Fixes bug in rfc2616 #3.6.1 implementation.
(props @stephenharris, [#236][gh-236], [#3][gh-3])
- CURLOPT_HTTPHEADER在php7接受空数组导致php-fpm奔溃
(props @qibinghua, [#219][gh-219])
[gh-3]: https://github.com/rmccue/Requests/issues/3
[gh-75]: https://github.com/rmccue/Requests/issues/75
[gh-86]: https://github.com/rmccue/Requests/issues/86
[gh-92]: https://github.com/rmccue/Requests/issues/92
[gh-97]: https://github.com/rmccue/Requests/issues/97
[gh-99]: https://github.com/rmccue/Requests/issues/99
[gh-101]: https://github.com/rmccue/Requests/issues/101
[gh-103]: https://github.com/rmccue/Requests/issues/103
[gh-104]: https://github.com/rmccue/Requests/issues/104
[gh-106]: https://github.com/rmccue/Requests/issues/106
[gh-107]: https://github.com/rmccue/Requests/issues/107
[gh-112]: https://github.com/rmccue/Requests/issues/112
[gh-113]: https://github.com/rmccue/Requests/issues/113
[gh-120]: https://github.com/rmccue/Requests/issues/120
[gh-124]: https://github.com/rmccue/Requests/issues/124
[gh-128]: https://github.com/rmccue/Requests/issues/128
[gh-130]: https://github.com/rmccue/Requests/issues/130
[gh-132]: https://github.com/rmccue/Requests/issues/132
[gh-136]: https://github.com/rmccue/Requests/issues/136
[gh-148]: https://github.com/rmccue/Requests/issues/148
[gh-150]: https://github.com/rmccue/Requests/issues/150
[gh-156]: https://github.com/rmccue/Requests/issues/156
[gh-158]: https://github.com/rmccue/Requests/issues/158
[gh-162]: https://github.com/rmccue/Requests/issues/162
[gh-164]: https://github.com/rmccue/Requests/issues/164
[gh-170]: https://github.com/rmccue/Requests/issues/170
[gh-172]: https://github.com/rmccue/Requests/issues/172
[gh-174]: https://github.com/rmccue/Requests/issues/174
[gh-176]: https://github.com/rmccue/Requests/issues/176
[gh-177]: https://github.com/rmccue/Requests/issues/177
[gh-179]: https://github.com/rmccue/Requests/issues/179
[gh-180]: https://github.com/rmccue/Requests/issues/180
[gh-181]: https://github.com/rmccue/Requests/issues/181
[gh-183]: https://github.com/rmccue/Requests/issues/183
[gh-184]: https://github.com/rmccue/Requests/issues/184
[gh-185]: https://github.com/rmccue/Requests/issues/185
[gh-186]: https://github.com/rmccue/Requests/issues/186
[gh-187]: https://github.com/rmccue/Requests/issues/187
[gh-188]: https://github.com/rmccue/Requests/issues/188
[gh-194]: https://github.com/rmccue/Requests/issues/194
[gh-196]: https://github.com/rmccue/Requests/issues/196
[gh-200]: https://github.com/rmccue/Requests/issues/200
[gh-202]: https://github.com/rmccue/Requests/issues/202
[gh-203]: https://github.com/rmccue/Requests/issues/203
[gh-205]: https://github.com/rmccue/Requests/issues/205
[gh-206]: https://github.com/rmccue/Requests/issues/206
[gh-207]: https://github.com/rmccue/Requests/issues/207
[gh-210]: https://github.com/rmccue/Requests/issues/210
[gh-211]: https://github.com/rmccue/Requests/issues/211
[gh-215]: https://github.com/rmccue/Requests/issues/215
[gh-216]: https://github.com/rmccue/Requests/issues/216
[gh-217]: https://github.com/rmccue/Requests/issues/217
[gh-219]: https://github.com/rmccue/Requests/issues/219
[gh-223]: https://github.com/rmccue/Requests/issues/223
[gh-224]: https://github.com/rmccue/Requests/issues/224
[gh-227]: https://github.com/rmccue/Requests/issues/227
[gh-230]: https://github.com/rmccue/Requests/issues/230
[gh-236]: https://github.com/rmccue/Requests/issues/236
[gh-237]: https://github.com/rmccue/Requests/issues/237
[gh-238]: https://github.com/rmccue/Requests/issues/238
[gh-239]: https://github.com/rmccue/Requests/issues/239
[gh-240]: https://github.com/rmccue/Requests/issues/240
1.6.0
-----
- [Add multiple request support][#23] - Send multiple HTTP requests with both
fsockopen and cURL, transparently falling back to synchronous when
not supported.
- [Add proxy support][#70] - HTTP proxies are now natively supported via a
[high-level API][docs/proxy]. Major props to Ozh for his fantastic work
on this.
- [Verify host name for SSL requests][#63] - Requests is now the first and only
standalone HTTP library to fully verify SSL hostnames even with socket
connections. Thanks to Michael Adams, Dion Hulse, Jon Cave, and Pádraic Brady
for reviewing the crucial code behind this.
- [Add cookie support][#64] - Adds built-in support for cookies (built entirely
as a high-level API)
- [Add sessions][#62] - To compliment cookies, [sessions][docs/usage-advanced]
can be created with a base URL and default options, plus a shared cookie jar.
- Add [PUT][#1], [DELETE][#3], and [PATCH][#2] request support
- [Add Composer support][#6] - You can now install Requests via the
`rmccue/requests` package on Composer
[docs/proxy]: http://requests.ryanmccue.info/docs/proxy.html
[docs/usage-advanced]: http://requests.ryanmccue.info/docs/usage-advanced.html
[#1]: https://github.com/rmccue/Requests/issues/1
[#2]: https://github.com/rmccue/Requests/issues/2
[#3]: https://github.com/rmccue/Requests/issues/3
[#6]: https://github.com/rmccue/Requests/issues/6
[#9]: https://github.com/rmccue/Requests/issues/9
[#23]: https://github.com/rmccue/Requests/issues/23
[#62]: https://github.com/rmccue/Requests/issues/62
[#63]: https://github.com/rmccue/Requests/issues/63
[#64]: https://github.com/rmccue/Requests/issues/64
[#70]: https://github.com/rmccue/Requests/issues/70
[View all changes][https://github.com/rmccue/Requests/compare/v1.5.0...v1.6.0]
1.5.0
-----
Initial release!

View file

@ -1,23 +0,0 @@
{
"name": "rmccue/requests",
"description": "A HTTP library written in PHP, for human beings.",
"homepage": "http://github.com/rmccue/Requests",
"license": "ISC",
"keywords": ["http", "idna", "iri", "ipv6", "curl", "sockets", "fsockopen"],
"authors": [
{
"name": "Ryan McCue",
"homepage": "http://ryanmccue.info"
}
],
"require": {
"php": ">=5.2"
},
"require-dev": {
"requests/test-server": "dev-master"
},
"type": "library",
"autoload": {
"psr-0": {"Requests": "library/"}
}
}

View file

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.8.0" version="2.0"
xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
<name>Requests</name>
<channel>pear.ryanmccue.info</channel>
<summary>A HTTP library written in PHP, for human beings.</summary>
<description>
Requests is a HTTP library written in PHP, for human beings. It is
roughly based on the API from the excellent Requests Python library.
Requests is ISC Licensed (similar to the new BSD license) and has
no dependencies.
</description>
<lead>
<name>Ryan McCue</name>
<user>rmccue</user>
<email>me+pear@ryanmccue dot info</email>
<active>yes</active>
</lead>
<date>{{ date }}</date>
<time>{{ time }}</time>
<version>
<release>{{ version }}</release>
<api>{{ api_version }}</api>
</version>
<stability>
<release>{{ stability }}</release>
<api>{{ stability }}</api>
</stability>
<license uri="https://github.com/rmccue/Requests/blob/master/LICENSE" filesource="LICENSE">ISC</license>
<notes>-</notes>
<contents>
<dir name="/">
<file name="CHANGELOG.md" role="doc" />
<file name="LICENSE" role="doc" />
<file name="README.md" role="doc" />
<dir name="library">
<file install-as="Requests.php" name="Requests.php" role="php" />
<dir name="Requests">
{{ files }}
</dir>
</dir>
<file name="library/Requests/Transport/cacert.pem" install-as="library/Requests/Transport/cacert.pem" role="data" />
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.2.0</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
</required>
</dependencies>
<phprelease />
</package>

View file

@ -0,0 +1,21 @@
codecov:
notify:
after_n_builds: 2
coverage:
round: nearest
# Status will be green when coverage is between 85 and 100%.
range: "85...100"
status:
project:
default:
threshold: 1%
paths:
- "library"
patch:
default:
threshold: 0%
paths:
- "library"
comment: false

View file

@ -0,0 +1,598 @@
Changelog
=========
1.8.0
-----
### IMPORTANT NOTES
#### Last release supporting PHP 5.2 - 5.5
Release 1.8.0 will be the last release with compatibility for PHP 5.2 - 5.5. With the next release (v2.0.0), the minimum PHP version will be bumped to 5.6.
#### Last release supporting PEAR distribution
Release 1.8.0 will be the last release to be distributed via PEAR. From release 2.0.0 onwards, consumers of this library will have to switch to Composer to receive updates.
### Overview of changes
- **[SECURITY FIX] Disable deserialization in `FilteredIterator`**
A `Deserialization of Untrusted Data` weakness was found in the `FilteredIterator` class.
This security vulnerability was first reported to the WordPress project. The security fix applied to WordPress has been ported back into the library.
GitHub security advisory: [CVE-2021-29476 - Deserialization of Untrusted Data](https://cve.mitre.org/cgi-bin/cvename.cgi?name=2021-29476)
Related WordPress CVE: [https://cve.mitre.org/cgi-bin/cvename.cgi?name=2020-28032](https://cve.mitre.org/cgi-bin/cvename.cgi?name=2020-28032)
(props [@dd32][gh-dd32], [@desrosj][gh-desrosj], [@jrfnl][gh-jrfnl], [@peterwilsoncc][gh-peterwilsoncc], [@SergeyBiryukov][gh-SergeyBiryukov], [@whyisjake][gh-whyisjake], [@xknown][gh-xknown], [#421][gh-421], [#422][gh-422])
- **Repository moved to `WordPress\Requests`**
The `Requests` library has been moved to the WordPress GitHub organization and can now be found under `https://github.com/WordPress/Requests`.
All links in code and documentation were updated accordingly.
Note: the Composer package name remains unchanged ([`rmccue/requests`](https://packagist.org/packages/rmccue/requests)), as well as the documentation site ([requests.ryanmccue.info](https://requests.ryanmccue.info/)).
(props [@dd32][gh-dd32], [@JustinyAhin][gh-JustinyAhin], [@jrfnl][gh-jrfnl], [@rmccue][gh-rmccue], [#440][gh-440], [#441][gh-441], [#448][gh-448])
- **Manage `"Expect"` header with `cURL` transport**
By default, `cURL` adds a `Expect: 100-Continue` header to certain requests. This can add as much as a second delay to requests done using `cURL`. This is [discussed on the cURL mailing list](https://curl.se/mail/lib-2017-07/0013.html).
To prevent this, `Requests` now adds an empty `"Expect"` header to requests that are smaller than 1 MB and use HTTP/1.1.
(props [@carlalexander][gh-carlalexander], [@schlessera][gh-schlessera], [@TimothyBJacobs][gh-TimothyBJacobs], [#453][gh-453], [#454][gh-454], [#469][gh-469])
- **Update bundled certificates as of 2021-02-12**
The bundled certificates were updated. A small subset of expired certificates are still included for legacy reasons (and support).
(props [@ozh][gh-ozh], [@patmead][gh-patmead], [@schlessera][gh-schlessera], [@todeveni][gh-todeveni], [#385][gh-385], [#398][gh-398], [#451][gh-451])
- **Add required `Content-*` headers for empty `POST` requests**
Sends the `Content-Length` and `Content-Type` headers even for empty `POST` requests, as the length is expected as per [RFC2616 Section 14.13](https://tools.ietf.org/html/rfc2616#section-14.13):
```
Content-Length header "SHOULD" be included. In practice, it is not
used for GET nor HEAD requests, but is expected for POST requests.
```
(props [@dd32][gh-dd32], [@gstrauss][gh-gstrauss], [@jrfnl][gh-jrfnl], [@soulseekah][gh-soulseekah], [#248][gh-248], [#249][gh-249], [#318][gh-318], [#368][gh-368])
- **Ignore locale when creating the HTTP version string from a float**
The previous behavior allowed for the locale to mess up the float to string conversion resulting in a `GET / HTTP/1,1` instead of `GET / HTTP/1.1` request.
(props [@tonebender][gh-tonebender], [@Zegnat][gh-Zegnat], [#335][gh-335], [#339][gh-339])
- **Make `verify => false` work with `fsockopen`**
This allows the `fsockopen` transport now to ignore SSL failures when requested.
(props [@soulseekah][gh-soulseekah], [#310][gh-310], [#311][gh-311])
- **Only include port number in the `Host` header if it differs from the default**
The code was not violating the RFC per se, but also not following standard practice of leaving the port off when it is the default port for the scheme, which could lead to connectivity issues.
(props [@amandato][gh-amandato], [@dd32][gh-dd32], [#238][gh-238])
- **Fix PHP cross-version compatibility**
Important fixes have been made to improve cross-version compatibility of the code across all supported PHP versions.
- Use documented order for `implode()` arguments.
- Harden type handling when no domain was passed.
- Explicitly cast `$url` property to `string` in `Requests::parse_response()`.
- Initialize `$body` property to an empty string in `Requests::parse_response()`.
- Ensure the stream handle is valid before trying to close it.
- Ensure the `$callback` in the `FilteredIterator` is callable before calling it.
(props [@aaronjorbin][gh-aaronjorbin], [@jrfnl][gh-jrfnl], [#346][gh-346], [#370][gh-370], [#425][gh-425], [#426][gh-426], [#456][gh-456], [#457][gh-457])
- **Improve testing**
Lots of improvements were made to render the tests more reliable and increase the coverage.
And to top it all off, all tests are now run against all supported PHP versions, including PHP 8.0.
(props [@datagutten][gh-datagutten], [@jrfnl][gh-jrfnl], [@schlessera][gh-schlessera], [#345][gh-345], [#351][gh-351], [#355][gh-355], [#366][gh-366], [#412][gh-412], [#414][gh-414], [#445][gh-445], [#458][gh-458], [#464][gh-464])
- **Improve code quality and style**
A whole swoop of changes has been made to harden the code and make it more consistent.
The code style has been made consistent across both code and tests and is now enforced via a custom PHPCS rule set.
The WordPress Coding Standards were chosen as the basis for the code style checks as most contributors to this library originate from the WordPress community and will be familiar with this code style.
Main differences from the WordPress Coding Standards based on discussions and an analysis of the code styles already in use:
- No whitespace on the inside of parentheses.
- No Yoda conditions.
A more detailed overview of the decisions that went into the final code style rules can be found at [#434][gh-434].
(props [@jrfnl][gh-jrfnl], [@KasperFranz][gh-KasperFranz], [@ozh][gh-ozh], [@schlessera][gh-schlessera], [@TysonAndre][gh-TysonAndre], [#263][gh-263], [#296][gh-296], [#328][gh-328], [#358][gh-358], [#359][gh-359], [#360][gh-360], [#361][gh-361], [#362][gh-362], [#363][gh-363], [#364][gh-364], [#386][gh-386], [#396][gh-396], [#399][gh-399], [#400][gh-400], [#401][gh-401], [#402][gh-402], [#403][gh-403], [#404][gh-404], [#405][gh-405], [#406][gh-406], [#408][gh-408], [#409][gh-409], [#410][gh-410], [#411][gh-411], [#413][gh-413], [#415][gh-415], [#416][gh-416], [#417][gh-417], [#423][gh-423], [#424][gh-424], [#434][gh-434])
- **Replace Travis CI with GitHub Actions (partial)**
The entire CI setup is gradually being moved from Travis CI to GitHub Actions.
At this point, GitHub Actions takes over the CI from PHP 5.5 onwards, leaving Travis CI as a fallback for lower PHP versions.
This move will be completed after the planned minimum version bump to PHP 5.6+ with the next release, at which point we will get rid of all the remaining Travis CI integrations.
(props [@dd32][gh-dd32], [@desrosj][gh-desrosj], [@jrfnl][gh-jrfnl], [@ntwb][gh-ntwb], [@ozh][gh-ozh], [@schlessera][gh-schlessera], [@TimothyBJacobs][gh-TimothyBJacobs], [@TysonAndre][gh-TysonAndre], [#280][gh-280], [#298][gh-298], [#302][gh-302], [#303][gh-303], [#352][gh-352], [#353][gh-353], [#354][gh-354], [#356][gh-356], [#388][gh-388], [#397][gh-397], [#428][gh-428], [#436][gh-436], [#439][gh-439], [#461][gh-461], [#467][gh-467])
- **Update and improve documentation**
- Use clearer and more inclusive language.
- Update the GitHub Pages site.
- Update content and various tweaks to the markdown.
- Fix code blocks in `README.md` file.
- Add pagination to documentation pages.
(props [@desrosj][gh-desrosj], [@jrfnl][gh-jrfnl], [@JustinyAhin][gh-JustinyAhin], [@tnorthcutt][gh-tnorthcutt], [#334][gh-334], [#367][gh-367], [#387][gh-387], [#443][gh-443], [#462][gh-462], [#465][gh-465], [#468][gh-468], [#471][gh-471] )
[gh-194]: https://github.com/WordPress/Requests/issues/194
[gh-238]: https://github.com/WordPress/Requests/issues/238
[gh-248]: https://github.com/WordPress/Requests/issues/248
[gh-249]: https://github.com/WordPress/Requests/issues/249
[gh-263]: https://github.com/WordPress/Requests/issues/263
[gh-280]: https://github.com/WordPress/Requests/issues/280
[gh-296]: https://github.com/WordPress/Requests/issues/296
[gh-298]: https://github.com/WordPress/Requests/issues/298
[gh-302]: https://github.com/WordPress/Requests/issues/302
[gh-303]: https://github.com/WordPress/Requests/issues/303
[gh-310]: https://github.com/WordPress/Requests/issues/310
[gh-311]: https://github.com/WordPress/Requests/issues/311
[gh-318]: https://github.com/WordPress/Requests/issues/318
[gh-328]: https://github.com/WordPress/Requests/issues/328
[gh-334]: https://github.com/WordPress/Requests/issues/334
[gh-335]: https://github.com/WordPress/Requests/issues/335
[gh-339]: https://github.com/WordPress/Requests/issues/339
[gh-345]: https://github.com/WordPress/Requests/issues/345
[gh-346]: https://github.com/WordPress/Requests/issues/346
[gh-351]: https://github.com/WordPress/Requests/issues/351
[gh-352]: https://github.com/WordPress/Requests/issues/352
[gh-353]: https://github.com/WordPress/Requests/issues/353
[gh-354]: https://github.com/WordPress/Requests/issues/354
[gh-355]: https://github.com/WordPress/Requests/issues/355
[gh-356]: https://github.com/WordPress/Requests/issues/356
[gh-358]: https://github.com/WordPress/Requests/issues/358
[gh-359]: https://github.com/WordPress/Requests/issues/359
[gh-360]: https://github.com/WordPress/Requests/issues/360
[gh-361]: https://github.com/WordPress/Requests/issues/361
[gh-362]: https://github.com/WordPress/Requests/issues/362
[gh-363]: https://github.com/WordPress/Requests/issues/363
[gh-364]: https://github.com/WordPress/Requests/issues/364
[gh-366]: https://github.com/WordPress/Requests/issues/366
[gh-367]: https://github.com/WordPress/Requests/issues/367
[gh-367]: https://github.com/WordPress/Requests/issues/367
[gh-368]: https://github.com/WordPress/Requests/issues/368
[gh-370]: https://github.com/WordPress/Requests/issues/370
[gh-385]: https://github.com/WordPress/Requests/issues/385
[gh-386]: https://github.com/WordPress/Requests/issues/386
[gh-387]: https://github.com/WordPress/Requests/issues/387
[gh-388]: https://github.com/WordPress/Requests/issues/388
[gh-396]: https://github.com/WordPress/Requests/issues/396
[gh-397]: https://github.com/WordPress/Requests/issues/397
[gh-398]: https://github.com/WordPress/Requests/issues/398
[gh-399]: https://github.com/WordPress/Requests/issues/399
[gh-400]: https://github.com/WordPress/Requests/issues/400
[gh-401]: https://github.com/WordPress/Requests/issues/401
[gh-402]: https://github.com/WordPress/Requests/issues/402
[gh-403]: https://github.com/WordPress/Requests/issues/403
[gh-404]: https://github.com/WordPress/Requests/issues/404
[gh-405]: https://github.com/WordPress/Requests/issues/405
[gh-406]: https://github.com/WordPress/Requests/issues/406
[gh-408]: https://github.com/WordPress/Requests/issues/408
[gh-409]: https://github.com/WordPress/Requests/issues/409
[gh-410]: https://github.com/WordPress/Requests/issues/410
[gh-411]: https://github.com/WordPress/Requests/issues/411
[gh-412]: https://github.com/WordPress/Requests/issues/412
[gh-413]: https://github.com/WordPress/Requests/issues/413
[gh-414]: https://github.com/WordPress/Requests/issues/414
[gh-415]: https://github.com/WordPress/Requests/issues/415
[gh-416]: https://github.com/WordPress/Requests/issues/416
[gh-417]: https://github.com/WordPress/Requests/issues/417
[gh-421]: https://github.com/WordPress/Requests/issues/421
[gh-422]: https://github.com/WordPress/Requests/issues/422
[gh-423]: https://github.com/WordPress/Requests/issues/423
[gh-424]: https://github.com/WordPress/Requests/issues/424
[gh-425]: https://github.com/WordPress/Requests/issues/425
[gh-426]: https://github.com/WordPress/Requests/issues/426
[gh-428]: https://github.com/WordPress/Requests/issues/428
[gh-434]: https://github.com/WordPress/Requests/issues/434
[gh-436]: https://github.com/WordPress/Requests/issues/436
[gh-439]: https://github.com/WordPress/Requests/issues/439
[gh-440]: https://github.com/WordPress/Requests/issues/440
[gh-441]: https://github.com/WordPress/Requests/issues/441
[gh-443]: https://github.com/WordPress/Requests/issues/443
[gh-445]: https://github.com/WordPress/Requests/issues/445
[gh-448]: https://github.com/WordPress/Requests/issues/448
[gh-451]: https://github.com/WordPress/Requests/issues/451
[gh-453]: https://github.com/WordPress/Requests/issues/453
[gh-454]: https://github.com/WordPress/Requests/issues/454
[gh-456]: https://github.com/WordPress/Requests/issues/456
[gh-457]: https://github.com/WordPress/Requests/issues/457
[gh-458]: https://github.com/WordPress/Requests/issues/458
[gh-461]: https://github.com/WordPress/Requests/issues/461
[gh-462]: https://github.com/WordPress/Requests/issues/462
[gh-464]: https://github.com/WordPress/Requests/issues/464
[gh-465]: https://github.com/WordPress/Requests/issues/465
[gh-467]: https://github.com/WordPress/Requests/issues/467
[gh-468]: https://github.com/WordPress/Requests/issues/468
[gh-469]: https://github.com/WordPress/Requests/issues/469
[gh-471]: https://github.com/WordPress/Requests/issues/471
1.7.0
-----
- Add support for HHVM and PHP 7
Requests is now tested against both HHVM and PHP 7, and they are supported as
first-party platforms.
(props [@rmccue][gh-rmccue], [#106][gh-106], [#176][gh-176])
- Transfer & connect timeouts, in seconds & milliseconds
cURL is unable to handle timeouts under a second in DNS lookups, so we round
those up to ensure 1-999ms isn't counted as an instant failure.
(props [@ozh][gh-ozh], [@rmccue][gh-rmccue], [#97][gh-97], [#216][gh-216])
- Rework cookie handling to be more thorough.
Cookies are now restricted to the same-origin by default, expiration is checked.
(props [@catharsisjelly][gh-catharsisjelly], [@rmccue][gh-rmccue], [#120][gh-120], [#124][gh-124], [#130][gh-130], [#132][gh-132], [#156][gh-156])
- Improve testing
Tests are now run locally to speed them up, as well as further general
improvements to the quality of the testing suite. There are now also
comprehensive proxy tests to ensure coverage there.
(props [@rmccue][gh-rmccue], [#75][gh-75], [#107][gh-107], [#170][gh-170], [#177][gh-177], [#181][gh-181], [#183][gh-183], [#185][gh-185], [#196][gh-196], [#202][gh-202], [#203][gh-203])
- Support custom HTTP methods
Previously, custom HTTP methods were only supported on sockets; they are now
supported across all transports.
(props [@ocean90][gh-ocean90], [#227][gh-227])
- Add byte limit option
(props [@rmccue][gh-rmccue], [#172][gh-172])
- Support a Requests_Proxy_HTTP() instance for the proxy setting.
(props [@ocean90][gh-ocean90], [#223][gh-223])
- Add progress hook
(props [@rmccue][gh-rmccue], [#180][gh-180])
- Add a before_redirect hook to alter redirects
(props [@rmccue][gh-rmccue], [#205][gh-205])
- Pass cURL info to after_request
(props [@rmccue][gh-rmccue], [#206][gh-206])
- Remove explicit autoload in Composer installation instructions
(props [@SlikNL][gh-SlikNL], [#86][gh-86])
- Restrict CURLOPT_PROTOCOLS on `defined()` instead of `version_compare()`
(props [@ozh][gh-ozh], [#92][gh-92])
- Fix doc - typo in "Authentication"
(props [@remik][gh-remik], [#99][gh-99])
- Contextually check for a valid transport
(props [@ozh][gh-ozh], [#101][gh-101])
- Follow relative redirects correctly
(props [@ozh][gh-ozh], [#103][gh-103])
- Use cURL's version_number
(props [@mishan][gh-mishan], [#104][gh-104])
- Removed duplicated option docs
(props [@staabm][gh-staabm], [#112][gh-112])
- code styling fixed
(props [@imsaintx][gh-imsaintx], [#113][gh-113])
- Fix IRI "normalization"
(props [@ozh][gh-ozh], [#128][gh-128])
- Mention two PHP extension dependencies in the README.
(props [@orlitzky][gh-orlitzky], [#136][gh-136])
- Ignore coverage report files
(props [@ozh][gh-ozh], [#148][gh-148])
- drop obsolete "return" after throw
(props [@staabm][gh-staabm], [#150][gh-150])
- Updated exception message to specify both http + https
(props [@beutnagel][gh-beutnagel], [#162][gh-162])
- Sets `stream_headers` method to public to allow calling it from other
places.
(props [@adri][gh-adri], [#158][gh-158])
- Remove duplicated stream_get_meta_data call
(props [@rmccue][gh-rmccue], [#179][gh-179])
- Transmits $errno from stream_socket_client in exception
(props [@laurentmartelli][gh-laurentmartelli], [#174][gh-174])
- Correct methods to use snake_case
(props [@rmccue][gh-rmccue], [#184][gh-184])
- Improve code quality
(props [@rmccue][gh-rmccue], [#186][gh-186])
- Update Build Status image
(props [@rmccue][gh-rmccue], [#187][gh-187])
- Fix/Rationalize transports (v2)
(props [@rmccue][gh-rmccue], [#188][gh-188])
- Surface cURL errors
(props [@ifwe][gh-ifwe], [#194][gh-194])
- Fix for memleak and curl_close() never being called
(props [@kwuerl][gh-kwuerl], [#200][gh-200])
- addex how to install with composer
(props [@royopa][gh-royopa], [#164][gh-164])
- Uppercase the method to ensure compatibility
(props [@rmccue][gh-rmccue], [#207][gh-207])
- Store default certificate path
(props [@rmccue][gh-rmccue], [#210][gh-210])
- Force closing keep-alive connections on old cURL
(props [@rmccue][gh-rmccue], [#211][gh-211])
- Docs: Updated HTTP links with HTTPS links where applicable
(props [@ntwb][gh-ntwb], [#215][gh-215])
- Remove the executable bit
(props [@ocean90][gh-ocean90], [#224][gh-224])
- Change more links to HTTPS
(props [@rmccue][gh-rmccue], [#217][gh-217])
- Bail from cURL when either `curl_init()` OR `curl_exec()` are unavailable
(props [@dd32][gh-dd32], [#230][gh-230])
- Disable OpenSSL's internal peer_name checking when `verifyname` is disabled.
(props [@dd32][gh-dd32], [#239][gh-239])
- Only include the port number in the `Host` header when it differs from
default
(props [@dd32][gh-dd32], [#238][gh-238])
- Respect port if specified for HTTPS connections
(props [@dd32][gh-dd32], [#237][gh-237])
- Allow paths starting with a double-slash
(props [@rmccue][gh-rmccue], [#240][gh-240])
- Fixes bug in rfc2616 #3.6.1 implementation.
(props [@stephenharris][gh-stephenharris], [#236][gh-236], [#3][gh-3])
- CURLOPT_HTTPHEADER在php7接受空数组导致php-fpm奔溃
(props [@qibinghua][gh-qibinghua], [#219][gh-219])
[gh-3]: https://github.com/WordPress/Requests/issues/3
[gh-75]: https://github.com/WordPress/Requests/issues/75
[gh-86]: https://github.com/WordPress/Requests/issues/86
[gh-92]: https://github.com/WordPress/Requests/issues/92
[gh-97]: https://github.com/WordPress/Requests/issues/97
[gh-99]: https://github.com/WordPress/Requests/issues/99
[gh-101]: https://github.com/WordPress/Requests/issues/101
[gh-103]: https://github.com/WordPress/Requests/issues/103
[gh-104]: https://github.com/WordPress/Requests/issues/104
[gh-106]: https://github.com/WordPress/Requests/issues/106
[gh-107]: https://github.com/WordPress/Requests/issues/107
[gh-112]: https://github.com/WordPress/Requests/issues/112
[gh-113]: https://github.com/WordPress/Requests/issues/113
[gh-120]: https://github.com/WordPress/Requests/issues/120
[gh-124]: https://github.com/WordPress/Requests/issues/124
[gh-128]: https://github.com/WordPress/Requests/issues/128
[gh-130]: https://github.com/WordPress/Requests/issues/130
[gh-132]: https://github.com/WordPress/Requests/issues/132
[gh-136]: https://github.com/WordPress/Requests/issues/136
[gh-148]: https://github.com/WordPress/Requests/issues/148
[gh-150]: https://github.com/WordPress/Requests/issues/150
[gh-156]: https://github.com/WordPress/Requests/issues/156
[gh-158]: https://github.com/WordPress/Requests/issues/158
[gh-162]: https://github.com/WordPress/Requests/issues/162
[gh-164]: https://github.com/WordPress/Requests/issues/164
[gh-170]: https://github.com/WordPress/Requests/issues/170
[gh-172]: https://github.com/WordPress/Requests/issues/172
[gh-174]: https://github.com/WordPress/Requests/issues/174
[gh-176]: https://github.com/WordPress/Requests/issues/176
[gh-177]: https://github.com/WordPress/Requests/issues/177
[gh-179]: https://github.com/WordPress/Requests/issues/179
[gh-180]: https://github.com/WordPress/Requests/issues/180
[gh-181]: https://github.com/WordPress/Requests/issues/181
[gh-183]: https://github.com/WordPress/Requests/issues/183
[gh-184]: https://github.com/WordPress/Requests/issues/184
[gh-185]: https://github.com/WordPress/Requests/issues/185
[gh-186]: https://github.com/WordPress/Requests/issues/186
[gh-187]: https://github.com/WordPress/Requests/issues/187
[gh-188]: https://github.com/WordPress/Requests/issues/188
[gh-194]: https://github.com/WordPress/Requests/issues/194
[gh-196]: https://github.com/WordPress/Requests/issues/196
[gh-200]: https://github.com/WordPress/Requests/issues/200
[gh-202]: https://github.com/WordPress/Requests/issues/202
[gh-203]: https://github.com/WordPress/Requests/issues/203
[gh-205]: https://github.com/WordPress/Requests/issues/205
[gh-206]: https://github.com/WordPress/Requests/issues/206
[gh-207]: https://github.com/WordPress/Requests/issues/207
[gh-210]: https://github.com/WordPress/Requests/issues/210
[gh-211]: https://github.com/WordPress/Requests/issues/211
[gh-215]: https://github.com/WordPress/Requests/issues/215
[gh-216]: https://github.com/WordPress/Requests/issues/216
[gh-217]: https://github.com/WordPress/Requests/issues/217
[gh-219]: https://github.com/WordPress/Requests/issues/219
[gh-223]: https://github.com/WordPress/Requests/issues/223
[gh-224]: https://github.com/WordPress/Requests/issues/224
[gh-227]: https://github.com/WordPress/Requests/issues/227
[gh-230]: https://github.com/WordPress/Requests/issues/230
[gh-236]: https://github.com/WordPress/Requests/issues/236
[gh-237]: https://github.com/WordPress/Requests/issues/237
[gh-238]: https://github.com/WordPress/Requests/issues/238
[gh-239]: https://github.com/WordPress/Requests/issues/239
[gh-240]: https://github.com/WordPress/Requests/issues/240
1.6.0
-----
- [Add multiple request support][#23] - Send multiple HTTP requests with both
fsockopen and cURL, transparently falling back to synchronous when
not supported.
- [Add proxy support][#70] - HTTP proxies are now natively supported via a
[high-level API][docs/proxy]. Major props to Ozh for his fantastic work
on this.
- [Verify host name for SSL requests][#63] - Requests is now the first and only
standalone HTTP library to fully verify SSL hostnames even with socket
connections. Thanks to Michael Adams, Dion Hulse, Jon Cave, and Pádraic Brady
for reviewing the crucial code behind this.
- [Add cookie support][#64] - Adds built-in support for cookies (built entirely
as a high-level API)
- [Add sessions][#62] - To compliment cookies, [sessions][docs/usage-advanced]
can be created with a base URL and default options, plus a shared cookie jar.
- Add [PUT][#1], [DELETE][#3], and [PATCH][#2] request support
- [Add Composer support][#6] - You can now install Requests via the
`rmccue/requests` package on Composer
[docs/proxy]: http://requests.ryanmccue.info/docs/proxy.html
[docs/usage-advanced]: http://requests.ryanmccue.info/docs/usage-advanced.html
[#1]: https://github.com/WordPress/Requests/issues/1
[#2]: https://github.com/WordPress/Requests/issues/2
[#3]: https://github.com/WordPress/Requests/issues/3
[#6]: https://github.com/WordPress/Requests/issues/6
[#9]: https://github.com/WordPress/Requests/issues/9
[#23]: https://github.com/WordPress/Requests/issues/23
[#62]: https://github.com/WordPress/Requests/issues/62
[#63]: https://github.com/WordPress/Requests/issues/63
[#64]: https://github.com/WordPress/Requests/issues/64
[#70]: https://github.com/WordPress/Requests/issues/70
[View all changes][https://github.com/WordPress/Requests/compare/v1.5.0...v1.6.0]
1.5.0
-----
Initial release!
[gh-aaronjorbin]: https://github.com/aaronjorbin
[gh-adri]: https://github.com/adri
[gh-amandato]: https://github.com/amandato
[gh-beutnagel]: https://github.com/beutnagel
[gh-carlalexander]: https://github.com/carlalexander
[gh-catharsisjelly]: https://github.com/catharsisjelly
[gh-datagutten]: https://github.com/datagutten
[gh-dd32]: https://github.com/dd32
[gh-desrosj]: https://github.com/desrosj
[gh-gstrauss]: https://github.com/gstrauss
[gh-ifwe]: https://github.com/ifwe
[gh-imsaintx]: https://github.com/imsaintx
[gh-JustinyAhin]: https://github.com/JustinyAhin
[gh-jrfnl]: https://github.com/jrfnl
[gh-KasperFranz]: https://github.com/KasperFranz
[gh-kwuerl]: https://github.com/kwuerl
[gh-laurentmartelli]: https://github.com/laurentmartelli
[gh-mishan]: https://github.com/mishan
[gh-ntwb]: https://github.com/ntwb
[gh-ocean90]: https://github.com/ocean90
[gh-orlitzky]: https://github.com/orlitzky
[gh-ozh]: https://github.com/ozh
[gh-patmead]: https://github.com/patmead
[gh-peterwilsoncc]: https://github.com/peterwilsoncc
[gh-qibinghua]: https://github.com/qibinghua
[gh-remik]: https://github.com/remik
[gh-rmccue]: https://github.com/rmccue
[gh-royopa]: https://github.com/royopa
[gh-schlessera]: https://github.com/schlessera
[gh-SergeyBiryukov]: https://github.com/SergeyBiryukov
[gh-SlikNL]: https://github.com/SlikNL
[gh-soulseekah]: https://github.com/soulseekah
[gh-staabm]: https://github.com/staabm
[gh-stephenharris]: https://github.com/stephenharris
[gh-TimothyBJacobs]: https://github.com/TimothyBJacobs
[gh-tnorthcutt]: https://github.com/tnorthcutt
[gh-todeveni]: https://github.com/todeveni
[gh-tonebender]: https://github.com/tonebender
[gh-TysonAndre]: https://github.com/TysonAndre
[gh-whyisjake]: https://github.com/whyisjake
[gh-xknown]: https://github.com/xknown
[gh-Zegnat]: https://github.com/Zegnat

View file

@ -1,13 +1,16 @@
Requests for PHP
================
[![Build Status](https://travis-ci.org/rmccue/Requests.svg?branch=master)](https://travis-ci.org/rmccue/Requests)
[![codecov.io](http://codecov.io/github/rmccue/Requests/coverage.svg?branch=master)](http://codecov.io/github/rmccue/Requests?branch=master)
[![CS](https://github.com/WordPress/Requests/actions/workflows/cs.yml/badge.svg)](https://github.com/WordPress/Requests/actions/workflows/cs.yml)
[![Lint](https://github.com/WordPress/Requests/actions/workflows/lint.yml/badge.svg)](https://github.com/WordPress/Requests/actions/workflows/lint.yml)
[![Test](https://github.com/WordPress/Requests/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/Requests/actions/workflows/test.yml)
[![CI PHP 5.2-5.4](https://travis-ci.org/WordPress/Requests.svg?branch=master)](https://travis-ci.org/WordPress/Requests)
[![codecov.io](http://codecov.io/github/WordPress/Requests/coverage.svg?branch=master)](http://codecov.io/github/WordPress/Requests?branch=master)
Requests is a HTTP library written in PHP, for human beings. It is roughly
based on the API from the excellent [Requests Python
library](http://python-requests.org/). Requests is [ISC
Licensed](https://github.com/rmccue/Requests/blob/master/LICENSE) (similar to
Licensed](https://github.com/WordPress/Requests/blob/master/LICENSE) (similar to
the new BSD license) and has no dependencies, except for PHP 5.2+.
Despite PHP's use as a language for the web, its tools for sending HTTP requests
@ -36,7 +39,7 @@ var_dump($request->body);
Requests allows you to send **HEAD**, **GET**, **POST**, **PUT**, **DELETE**,
and **PATCH** HTTP requests. You can add headers, form data, multipart files,
and parameters with simple arrays, and access the response data in the same way.
and parameters with basic arrays, and access the response data in the same way.
Requests uses cURL and fsockopen, depending on what your system has available,
but abstracts all the nasty stuff out of your way, providing a consistent API.
@ -63,43 +66,49 @@ composer require rmccue/requests
```
or
{
"require": {
"rmccue/requests": ">=1.0"
}
```json
{
"require": {
"rmccue/requests": ">=1.0"
}
}
```
### Install source from GitHub
To install the source code:
$ git clone git://github.com/rmccue/Requests.git
```bash
$ git clone git://github.com/WordPress/Requests.git
```
And include it in your scripts:
require_once '/path/to/Requests/library/Requests.php';
```php
require_once '/path/to/Requests/library/Requests.php';
```
You'll probably also want to register an autoloader:
Requests::register_autoloader();
```php
Requests::register_autoloader();
```
### Install source from zip/tarball
Alternatively, you can fetch a [tarball][] or [zipball][]:
$ curl -L https://github.com/rmccue/Requests/tarball/master | tar xzv
(or)
$ wget https://github.com/rmccue/Requests/tarball/master -O - | tar xzv
```bash
$ curl -L https://github.com/WordPress/Requests/tarball/master | tar xzv
(or)
$ wget https://github.com/WordPress/Requests/tarball/master -O - | tar xzv
```
[tarball]: https://github.com/rmccue/Requests/tarball/master
[zipball]: https://github.com/rmccue/Requests/zipball/master
[tarball]: https://github.com/WordPress/Requests/tarball/master
[zipball]: https://github.com/WordPress/Requests/zipball/master
### Using a Class Loader
If you're using a class loader (e.g., [Symfony Class Loader][]) for
[PSR-0][]-style class loading:
$loader->registerPrefix('Requests', 'path/to/vendor/Requests/library');
```php
$loader->registerPrefix('Requests', 'path/to/vendor/Requests/library');
```
[Symfony Class Loader]: https://github.com/symfony/ClassLoader
[PSR-0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
@ -116,9 +125,9 @@ documented.
Requests is [100% documented with PHPDoc](http://requests.ryanmccue.info/api/).
If you find any problems with it, [create a new
issue](https://github.com/rmccue/Requests/issues/new)!
issue](https://github.com/WordPress/Requests/issues/new)!
[prose-based documentation]: https://github.com/rmccue/Requests/blob/master/docs/README.md
[prose-based documentation]: https://github.com/WordPress/Requests/blob/master/docs/README.md
[request_method]: http://requests.ryanmccue.info/api/class-Requests.html#_request
Testing
@ -127,18 +136,19 @@ Testing
Requests strives to have 100% code-coverage of the library with an extensive
set of tests. We're not quite there yet, but [we're getting close][codecov].
[codecov]: http://codecov.io/github/rmccue/Requests
[codecov]: http://codecov.io/github/WordPress/Requests
To run the test suite, first check that you have the [PHP
JSON extension ](http://php.net/manual/en/book.json.php) enabled. Then
simply:
$ cd tests
$ phpunit
```bash
$ phpunit
```
If you'd like to run a single set of tests, specify just the name:
$ phpunit Transport/cURL
```bash
$ phpunit Transport/cURL
```
Contribute
----------
@ -149,4 +159,4 @@ Contribute
3. Write a test which shows that the bug was fixed or that the feature works as expected
4. Send a pull request and bug me until I merge it
[the repository]: https://github.com/rmccue/Requests
[the repository]: https://github.com/WordPress/Requests

View file

@ -0,0 +1,47 @@
{
"name": "rmccue/requests",
"description": "A HTTP library written in PHP, for human beings.",
"homepage": "http://github.com/WordPress/Requests",
"license": "ISC",
"keywords": ["http", "idna", "iri", "ipv6", "curl", "sockets", "fsockopen"],
"authors": [
{
"name": "Ryan McCue",
"homepage": "http://ryanmccue.info"
}
],
"require": {
"php": ">=5.2"
},
"require-dev": {
"requests/test-server": "dev-master",
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5",
"squizlabs/php_codesniffer": "^3.5",
"phpcompatibility/php-compatibility": "^9.0",
"wp-coding-standards/wpcs": "^2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-parallel-lint/php-parallel-lint": "^1.3",
"php-parallel-lint/php-console-highlighter": "^0.5.0"
},
"type": "library",
"autoload": {
"psr-0": {"Requests": "library/"}
},
"scripts" : {
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"checkcs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs"
],
"fixcs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
],
"coverage": [
"@php ./vendor/phpunit/phpunit/phpunit"
]
}
}

View file

@ -143,7 +143,7 @@ class Requests {
$file = str_replace('_', '/', $class);
if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
require_once(dirname(__FILE__) . '/' . $file . '.php');
require_once dirname(__FILE__) . '/' . $file . '.php';
}
}
@ -187,7 +187,8 @@ class Requests {
// Don't search for a transport if it's already been done for these $capabilities
if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) {
return new self::$transport[$cap_string]();
$class = self::$transport[$cap_string];
return new $class();
}
// @codeCoverageIgnoreEnd
@ -214,7 +215,8 @@ class Requests {
throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
}
return new self::$transport[$cap_string]();
$class = self::$transport[$cap_string];
return new $class();
}
/**#@+
@ -340,7 +342,7 @@ class Requests {
* across transports.)
* (string|boolean, default: library/Requests/Transport/cacert.pem)
* - `verifyname`: Should we verify the common name in the SSL certificate?
* (boolean: default, true)
* (boolean, default: true)
* - `data_format`: How should we send the `$data` parameter?
* (string, one of 'query' or 'body', default: 'query' for
* HEAD/GET/DELETE, 'body' for POST/PUT/OPTIONS/PATCH)
@ -372,9 +374,9 @@ class Requests {
}
}
else {
$need_ssl = (0 === stripos($url, 'https://'));
$need_ssl = (stripos($url, 'https://') === 0);
$capabilities = array('ssl' => $need_ssl);
$transport = self::get_transport($capabilities);
$transport = self::get_transport($capabilities);
}
$response = $transport->request($url, $headers, $data, $options);
@ -445,7 +447,7 @@ class Requests {
$request['type'] = self::GET;
}
if (!isset($request['options'])) {
$request['options'] = $options;
$request['options'] = $options;
$request['options']['type'] = $request['type'];
}
else {
@ -501,25 +503,25 @@ class Requests {
*/
protected static function get_default_options($multirequest = false) {
$defaults = array(
'timeout' => 10,
'connect_timeout' => 10,
'useragent' => 'php-requests/' . self::VERSION,
'timeout' => 10,
'connect_timeout' => 10,
'useragent' => 'php-requests/' . self::VERSION,
'protocol_version' => 1.1,
'redirected' => 0,
'redirects' => 10,
'redirected' => 0,
'redirects' => 10,
'follow_redirects' => true,
'blocking' => true,
'type' => self::GET,
'filename' => false,
'auth' => false,
'proxy' => false,
'cookies' => false,
'max_bytes' => false,
'idn' => true,
'hooks' => null,
'transport' => null,
'verify' => Requests::get_certificate_path(),
'verifyname' => true,
'blocking' => true,
'type' => self::GET,
'filename' => false,
'auth' => false,
'proxy' => false,
'cookies' => false,
'max_bytes' => false,
'idn' => true,
'hooks' => null,
'transport' => null,
'verify' => self::get_certificate_path(),
'verifyname' => true,
);
if ($multirequest !== false) {
$defaults['complete'] = null;
@ -533,8 +535,8 @@ class Requests {
* @return string Default certificate path.
*/
public static function get_certificate_path() {
if ( ! empty( Requests::$certificate_path ) ) {
return Requests::$certificate_path;
if (!empty(self::$certificate_path)) {
return self::$certificate_path;
}
return dirname(__FILE__) . '/Requests/Transport/cacert.pem';
@ -545,8 +547,8 @@ class Requests {
*
* @param string $path Certificate path, pointing to a PEM file.
*/
public static function set_certificate_path( $path ) {
Requests::$certificate_path = $path;
public static function set_certificate_path($path) {
self::$certificate_path = $path;
}
/**
@ -593,16 +595,16 @@ class Requests {
}
if ($options['idn'] !== false) {
$iri = new Requests_IRI($url);
$iri = new Requests_IRI($url);
$iri->host = Requests_IDNAEncoder::encode($iri->ihost);
$url = $iri->uri;
$url = $iri->uri;
}
// Massage the type to ensure we support it.
$type = strtoupper($type);
if (!isset($options['data_format'])) {
if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) {
if (in_array($type, array(self::HEAD, self::GET, self::DELETE), true)) {
$options['data_format'] = 'query';
}
else {
@ -631,20 +633,23 @@ class Requests {
return $return;
}
$return->raw = $headers;
$return->url = $url;
$return->raw = $headers;
$return->url = (string) $url;
$return->body = '';
if (!$options['filename']) {
if (($pos = strpos($headers, "\r\n\r\n")) === false) {
$pos = strpos($headers, "\r\n\r\n");
if ($pos === false) {
// Crap!
throw new Requests_Exception('Missing header/body separator', 'requests.no_crlf_separator');
}
$headers = substr($return->raw, 0, $pos);
$return->body = substr($return->raw, $pos + strlen("\n\r\n\r"));
}
else {
$return->body = '';
// Headers will always be separated from the body by two new lines - `\n\r\n\r`.
$body = substr($return->raw, $pos + 4);
if (!empty($body)) {
$return->body = $body;
}
}
// Pretend CRLF = LF for compatibility (RFC 2616, section 19.3)
$headers = str_replace("\r\n", "\n", $headers);
@ -656,14 +661,14 @@ class Requests {
throw new Requests_Exception('Response could not be parsed', 'noversion', $headers);
}
$return->protocol_version = (float) $matches[1];
$return->status_code = (int) $matches[2];
$return->status_code = (int) $matches[2];
if ($return->status_code >= 200 && $return->status_code < 300) {
$return->success = true;
}
foreach ($headers as $header) {
list($key, $value) = explode(':', $header, 2);
$value = trim($value);
$value = trim($value);
preg_replace('#(\s+)#i', ' ', $value);
$return->headers[$key] = $value;
}
@ -700,10 +705,10 @@ class Requests {
&$req_headers,
&$req_data,
&$options,
$return
$return,
);
$options['hooks']->dispatch('requests.before_redirect', $hook_args);
$redirected = self::request($location, $req_headers, $req_data, $options['type'], $options);
$redirected = self::request($location, $req_headers, $req_data, $options['type'], $options);
$redirected->history[] = $return;
return $redirected;
}
@ -730,10 +735,10 @@ class Requests {
*/
public static function parse_multiple(&$response, $request) {
try {
$url = $request['url'];
$headers = $request['headers'];
$data = $request['data'];
$options = $request['options'];
$url = $request['url'];
$headers = $request['headers'];
$data = $request['data'];
$options = $request['options'];
$response = self::parse_response($response, $url, $headers, $data, $options);
}
catch (Requests_Exception $e) {
@ -753,8 +758,6 @@ class Requests {
return $data;
}
$decoded = '';
$encoded = $data;
@ -772,8 +775,8 @@ class Requests {
}
$chunk_length = strlen($matches[0]);
$decoded .= substr($encoded, $chunk_length, $length);
$encoded = substr($encoded, $chunk_length + $length + 2);
$decoded .= substr($encoded, $chunk_length, $length);
$encoded = substr($encoded, $chunk_length + $length + 2);
if (trim($encoded) === '0' || empty($encoded)) {
return $decoded;
@ -826,17 +829,31 @@ class Requests {
return $data;
}
if (function_exists('gzdecode') && ($decoded = @gzdecode($data)) !== false) {
if (function_exists('gzdecode')) {
// phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.gzdecodeFound -- Wrapped in function_exists() for PHP 5.2.
$decoded = @gzdecode($data);
if ($decoded !== false) {
return $decoded;
}
}
if (function_exists('gzinflate')) {
$decoded = @gzinflate($data);
if ($decoded !== false) {
return $decoded;
}
}
$decoded = self::compatible_gzinflate($data);
if ($decoded !== false) {
return $decoded;
}
elseif (function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) {
return $decoded;
}
elseif (($decoded = self::compatible_gzinflate($data)) !== false) {
return $decoded;
}
elseif (function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) {
return $decoded;
if (function_exists('gzuncompress')) {
$decoded = @gzuncompress($data);
if ($decoded !== false) {
return $decoded;
}
}
return $data;
@ -859,32 +876,32 @@ class Requests {
* @link https://secure.php.net/manual/en/function.gzinflate.php#70875
* @link https://secure.php.net/manual/en/function.gzinflate.php#77336
*
* @param string $gzData String to decompress.
* @param string $gz_data String to decompress.
* @return string|bool False on failure.
*/
public static function compatible_gzinflate($gzData) {
public static function compatible_gzinflate($gz_data) {
// Compressed data might contain a full zlib header, if so strip it for
// gzinflate()
if (substr($gzData, 0, 3) == "\x1f\x8b\x08") {
$i = 10;
$flg = ord(substr($gzData, 3, 1));
if (substr($gz_data, 0, 3) === "\x1f\x8b\x08") {
$i = 10;
$flg = ord(substr($gz_data, 3, 1));
if ($flg > 0) {
if ($flg & 4) {
list($xlen) = unpack('v', substr($gzData, $i, 2));
$i = $i + 2 + $xlen;
list($xlen) = unpack('v', substr($gz_data, $i, 2));
$i += 2 + $xlen;
}
if ($flg & 8) {
$i = strpos($gzData, "\0", $i) + 1;
$i = strpos($gz_data, "\0", $i) + 1;
}
if ($flg & 16) {
$i = strpos($gzData, "\0", $i) + 1;
$i = strpos($gz_data, "\0", $i) + 1;
}
if ($flg & 2) {
$i = $i + 2;
$i += 2;
}
}
$decompressed = self::compatible_gzinflate(substr($gzData, $i));
if (false !== $decompressed) {
$decompressed = self::compatible_gzinflate(substr($gz_data, $i));
if ($decompressed !== false) {
return $decompressed;
}
}
@ -900,57 +917,61 @@ class Requests {
$huffman_encoded = false;
// low nibble of first byte should be 0x08
list(, $first_nibble) = unpack('h', $gzData);
list(, $first_nibble) = unpack('h', $gz_data);
// First 2 bytes should be divisible by 0x1F
list(, $first_two_bytes) = unpack('n', $gzData);
list(, $first_two_bytes) = unpack('n', $gz_data);
if (0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) {
if ($first_nibble === 0x08 && ($first_two_bytes % 0x1F) === 0) {
$huffman_encoded = true;
}
if ($huffman_encoded) {
if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) {
$decompressed = @gzinflate(substr($gz_data, 2));
if ($decompressed !== false) {
return $decompressed;
}
}
if ("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) {
if (substr($gz_data, 0, 4) === "\x50\x4b\x03\x04") {
// ZIP file format header
// Offset 6: 2 bytes, General-purpose field
// Offset 26: 2 bytes, filename length
// Offset 28: 2 bytes, optional field length
// Offset 30: Filename field, followed by optional field, followed
// immediately by data
list(, $general_purpose_flag) = unpack('v', substr($gzData, 6, 2));
list(, $general_purpose_flag) = unpack('v', substr($gz_data, 6, 2));
// If the file has been compressed on the fly, 0x08 bit is set of
// the general purpose field. We can use this to differentiate
// between a compressed document, and a ZIP file
$zip_compressed_on_the_fly = (0x08 == (0x08 & $general_purpose_flag));
$zip_compressed_on_the_fly = ((0x08 & $general_purpose_flag) === 0x08);
if (!$zip_compressed_on_the_fly) {
// Don't attempt to decode a compressed zip file
return $gzData;
return $gz_data;
}
// Determine the first byte of data, based on the above ZIP header
// offsets:
$first_file_start = array_sum(unpack('v2', substr($gzData, 26, 4)));
if (false !== ($decompressed = @gzinflate(substr($gzData, 30 + $first_file_start)))) {
$first_file_start = array_sum(unpack('v2', substr($gz_data, 26, 4)));
$decompressed = @gzinflate(substr($gz_data, 30 + $first_file_start));
if ($decompressed !== false) {
return $decompressed;
}
return false;
}
// Finally fall back to straight gzinflate
if (false !== ($decompressed = @gzinflate($gzData))) {
$decompressed = @gzinflate($gz_data);
if ($decompressed !== false) {
return $decompressed;
}
// Fallback for all above failing, not expected, but included for
// debugging and preventing regressions and to track stats
if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) {
$decompressed = @gzinflate(substr($gz_data, 2));
if ($decompressed !== false) {
return $decompressed;
}

View file

@ -29,5 +29,5 @@ interface Requests_Auth {
* @see Requests_Hooks::register
* @param Requests_Hooks $hooks Hook system
*/
public function register(Requests_Hooks &$hooks);
}
public function register(Requests_Hooks $hooks);
}

View file

@ -53,9 +53,9 @@ class Requests_Auth_Basic implements Requests_Auth {
* @see fsockopen_header
* @param Requests_Hooks $hooks Hook system
*/
public function register(Requests_Hooks &$hooks) {
$hooks->register('curl.before_send', array(&$this, 'curl_before_send'));
$hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header'));
public function register(Requests_Hooks $hooks) {
$hooks->register('curl.before_send', array($this, 'curl_before_send'));
$hooks->register('fsockopen.after_headers', array($this, 'fsockopen_header'));
}
/**
@ -85,4 +85,4 @@ class Requests_Auth_Basic implements Requests_Auth {
public function getAuthString() {
return $this->user . ':' . $this->pass;
}
}
}

View file

@ -65,16 +65,16 @@ class Requests_Cookie {
* @param array|Requests_Utility_CaseInsensitiveDictionary $attributes Associative array of attribute data
*/
public function __construct($name, $value, $attributes = array(), $flags = array(), $reference_time = null) {
$this->name = $name;
$this->value = $value;
$this->name = $name;
$this->value = $value;
$this->attributes = $attributes;
$default_flags = array(
'creation' => time(),
$default_flags = array(
'creation' => time(),
'last-access' => time(),
'persistent' => false,
'host-only' => true,
'persistent' => false,
'host-only' => true,
);
$this->flags = array_merge($default_flags, $flags);
$this->flags = array_merge($default_flags, $flags);
$this->reference_time = time();
if ($reference_time !== null) {
@ -228,7 +228,7 @@ class Requests_Cookie {
public function normalize() {
foreach ($this->attributes as $key => $value) {
$orig_value = $value;
$value = $this->normalize_attribute($key, $value);
$value = $this->normalize_attribute($key, $value);
if ($value === null) {
unset($this->attributes[$key]);
continue;
@ -288,6 +288,11 @@ class Requests_Cookie {
return $expiry_time;
case 'domain':
// Domains are not required as per RFC 6265 section 5.2.3
if (empty($value)) {
return null;
}
// Domain normalization, as per RFC 6265 section 5.2.3
if ($value[0] === '.') {
$value = substr($value, 1);
@ -380,7 +385,7 @@ class Requests_Cookie {
* @return Requests_Cookie Parsed cookie object
*/
public static function parse($string, $name = '', $reference_time = null) {
$parts = explode(';', $string);
$parts = explode(';', $string);
$kvparts = array_shift($parts);
if (!empty($name)) {
@ -392,13 +397,13 @@ class Requests_Cookie {
// (`=foo`)
//
// https://bugzilla.mozilla.org/show_bug.cgi?id=169091
$name = '';
$name = '';
$value = $kvparts;
}
else {
list($name, $value) = explode('=', $kvparts, 2);
}
$name = trim($name);
$name = trim($name);
$value = trim($value);
// Attribute key are handled case-insensitively
@ -407,15 +412,15 @@ class Requests_Cookie {
if (!empty($parts)) {
foreach ($parts as $part) {
if (strpos($part, '=') === false) {
$part_key = $part;
$part_key = $part;
$part_value = true;
}
else {
list($part_key, $part_value) = explode('=', $part, 2);
$part_value = trim($part_value);
$part_value = trim($part_value);
}
$part_key = trim($part_key);
$part_key = trim($part_key);
$attributes[$part_key] = $part_value;
}
}
@ -444,7 +449,7 @@ class Requests_Cookie {
// Default domain/path attributes
if (empty($parsed->attributes['domain']) && !empty($origin)) {
$parsed->attributes['domain'] = $origin->host;
$parsed->flags['host-only'] = true;
$parsed->flags['host-only'] = true;
}
else {
$parsed->flags['host-only'] = false;
@ -492,7 +497,7 @@ class Requests_Cookie {
*
* @codeCoverageIgnore
* @deprecated Use {@see Requests_Cookie::parse_from_headers}
* @return string
* @return array
*/
public static function parseFromHeaders(Requests_Response_Headers $headers) {
return self::parse_from_headers($headers);

View file

@ -68,7 +68,7 @@ class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate {
* Get the value for the item
*
* @param string $key Item key
* @return string Item value
* @return string|null Item value (null if offsetExists is false)
*/
public function offsetGet($key) {
if (!isset($this->cookies[$key])) {
@ -162,14 +162,14 @@ class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate {
*
* @var Requests_Response $response
*/
public function before_redirect_check(Requests_Response &$return) {
public function before_redirect_check(Requests_Response $return) {
$url = $return->url;
if (!$url instanceof Requests_IRI) {
$url = new Requests_IRI($url);
}
$cookies = Requests_Cookie::parse_from_headers($return->headers, $url);
$this->cookies = array_merge($this->cookies, $cookies);
$cookies = Requests_Cookie::parse_from_headers($return->headers, $url);
$this->cookies = array_merge($this->cookies, $cookies);
$return->cookies = $this;
}
}
}

View file

@ -59,4 +59,4 @@ class Requests_Exception extends Exception {
public function getData() {
return $this->data;
}
}
}

View file

@ -68,4 +68,4 @@ class Requests_Exception_HTTP extends Requests_Exception {
return 'Requests_Exception_HTTP_Unknown';
}
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_304 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Not Modified';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_400 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Bad Request';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_401 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Unauthorized';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_402 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Payment Required';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_403 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Forbidden';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_404 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Not Found';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_405 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Method Not Allowed';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_406 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Not Acceptable';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_407 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Proxy Authentication Required';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_408 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Request Timeout';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_409 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Conflict';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_410 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Gone';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_411 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Length Required';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_412 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Precondition Failed';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_413 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Request Entity Too Large';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Request-URI Too Large';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_415 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Unsupported Media Type';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_416 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Requested Range Not Satisfiable';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_417 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Expectation Failed';
}
}

View file

@ -26,4 +26,4 @@ class Requests_Exception_HTTP_418 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = "I'm A Teapot";
}
}

View file

@ -26,4 +26,4 @@ class Requests_Exception_HTTP_428 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Precondition Required';
}
}

View file

@ -26,4 +26,4 @@ class Requests_Exception_HTTP_429 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Too Many Requests';
}
}

View file

@ -26,4 +26,4 @@ class Requests_Exception_HTTP_431 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Request Header Fields Too Large';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_500 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Internal Server Error';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_501 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Not Implemented';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_502 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Bad Gateway';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_503 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Service Unavailable';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_504 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Gateway Timeout';
}
}

View file

@ -24,4 +24,4 @@ class Requests_Exception_HTTP_505 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'HTTP Version Not Supported';
}
}

View file

@ -26,4 +26,4 @@ class Requests_Exception_HTTP_511 extends Requests_Exception_HTTP {
* @var string
*/
protected $reason = 'Network Authentication Required';
}
}

View file

@ -41,4 +41,4 @@ class Requests_Exception_HTTP_Unknown extends Requests_Exception_HTTP {
parent::__construct($reason, $data);
}
}
}

View file

@ -2,7 +2,7 @@
class Requests_Exception_Transport_cURL extends Requests_Exception_Transport {
const EASY = 'cURLEasy';
const EASY = 'cURLEasy';
const MULTI = 'cURLMulti';
const SHARE = 'cURLShare';

View file

@ -30,4 +30,4 @@ interface Requests_Hooker {
* @return boolean Successfulness
*/
public function dispatch($hook, $parameters = array());
}
}

View file

@ -141,31 +141,32 @@ class Requests_IDNAEncoder {
// Get number of bytes
$strlen = strlen($input);
// phpcs:ignore Generic.CodeAnalysis.JumbledIncrementer -- This is a deliberate choice.
for ($position = 0; $position < $strlen; $position++) {
$value = ord($input[$position]);
// One byte sequence:
if ((~$value & 0x80) === 0x80) {
$character = $value;
$length = 1;
$length = 1;
$remaining = 0;
}
// Two byte sequence:
elseif (($value & 0xE0) === 0xC0) {
$character = ($value & 0x1F) << 6;
$length = 2;
$length = 2;
$remaining = 1;
}
// Three byte sequence:
elseif (($value & 0xF0) === 0xE0) {
$character = ($value & 0x0F) << 12;
$length = 3;
$length = 3;
$remaining = 2;
}
// Four byte sequence:
elseif (($value & 0xF8) === 0xF0) {
$character = ($value & 0x07) << 18;
$length = 4;
$length = 4;
$remaining = 3;
}
// Invalid byte:
@ -185,14 +186,14 @@ class Requests_IDNAEncoder {
throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character);
}
$character |= ($value & 0x3F) << (--$remaining * 6);
--$remaining;
$character |= ($value & 0x3F) << ($remaining * 6);
}
$position--;
}
if (
// Non-shortest form sequences are invalid
$length > 1 && $character <= 0x7F
if (// Non-shortest form sequences are invalid
$length > 1 && $character <= 0x7F
|| $length > 2 && $character <= 0x7FF
|| $length > 3 && $character <= 0xFFFF
// Outside of range of ucschar codepoints
@ -201,7 +202,7 @@ class Requests_IDNAEncoder {
|| $character >= 0xFDD0 && $character <= 0xFDEF
|| (
// Everything else not in ucschar
$character > 0xD7FF && $character < 0xF900
$character > 0xD7FF && $character < 0xF900
|| $character < 0x20
|| $character > 0x7E && $character < 0xA0
|| $character > 0xEFFFD
@ -227,17 +228,18 @@ class Requests_IDNAEncoder {
*/
public static function punycode_encode($input) {
$output = '';
# let n = initial_n
// let n = initial_n
$n = self::BOOTSTRAP_INITIAL_N;
# let delta = 0
// let delta = 0
$delta = 0;
# let bias = initial_bias
// let bias = initial_bias
$bias = self::BOOTSTRAP_INITIAL_BIAS;
# let h = b = the number of basic code points in the input
$h = $b = 0; // see loop
# copy them to the output in order
// let h = b = the number of basic code points in the input
$h = 0;
$b = 0; // see loop
// copy them to the output in order
$codepoints = self::utf8_to_codepoints($input);
$extended = array();
$extended = array();
foreach ($codepoints as $char) {
if ($char < 128) {
@ -260,35 +262,36 @@ class Requests_IDNAEncoder {
$extended = array_keys($extended);
sort($extended);
$b = $h;
# [copy them] followed by a delimiter if b > 0
// [copy them] followed by a delimiter if b > 0
if (strlen($output) > 0) {
$output .= '-';
}
# {if the input contains a non-basic code point < n then fail}
# while h < length(input) do begin
while ($h < count($codepoints)) {
# let m = the minimum code point >= n in the input
// {if the input contains a non-basic code point < n then fail}
// while h < length(input) do begin
$codepointcount = count($codepoints);
while ($h < $codepointcount) {
// let m = the minimum code point >= n in the input
$m = array_shift($extended);
//printf('next code point to insert is %s' . PHP_EOL, dechex($m));
# let delta = delta + (m - n) * (h + 1), fail on overflow
// let delta = delta + (m - n) * (h + 1), fail on overflow
$delta += ($m - $n) * ($h + 1);
# let n = m
// let n = m
$n = $m;
# for each code point c in the input (in order) do begin
for ($num = 0; $num < count($codepoints); $num++) {
// for each code point c in the input (in order) do begin
for ($num = 0; $num < $codepointcount; $num++) {
$c = $codepoints[$num];
# if c < n then increment delta, fail on overflow
// if c < n then increment delta, fail on overflow
if ($c < $n) {
$delta++;
}
# if c == n then begin
// if c == n then begin
elseif ($c === $n) {
# let q = delta
// let q = delta
$q = $delta;
# for k = base to infinity in steps of base do begin
// for k = base to infinity in steps of base do begin
for ($k = self::BOOTSTRAP_BASE; ; $k += self::BOOTSTRAP_BASE) {
# let t = tmin if k <= bias {+ tmin}, or
# tmax if k >= bias + tmax, or k - bias otherwise
// let t = tmin if k <= bias {+ tmin}, or
// tmax if k >= bias + tmax, or k - bias otherwise
if ($k <= ($bias + self::BOOTSTRAP_TMIN)) {
$t = self::BOOTSTRAP_TMIN;
}
@ -298,34 +301,30 @@ class Requests_IDNAEncoder {
else {
$t = $k - $bias;
}
# if q < t then break
// if q < t then break
if ($q < $t) {
break;
}
# output the code point for digit t + ((q - t) mod (base - t))
$digit = $t + (($q - $t) % (self::BOOTSTRAP_BASE - $t));
// output the code point for digit t + ((q - t) mod (base - t))
$digit = $t + (($q - $t) % (self::BOOTSTRAP_BASE - $t));
$output .= self::digit_to_char($digit);
# let q = (q - t) div (base - t)
// let q = (q - t) div (base - t)
$q = floor(($q - $t) / (self::BOOTSTRAP_BASE - $t));
# end
}
# output the code point for digit q
} // end
// output the code point for digit q
$output .= self::digit_to_char($q);
# let bias = adapt(delta, h + 1, test h equals b?)
// let bias = adapt(delta, h + 1, test h equals b?)
$bias = self::adapt($delta, $h + 1, $h === $b);
# let delta = 0
// let delta = 0
$delta = 0;
# increment h
// increment h
$h++;
# end
}
# end
}
# increment delta and n
} // end
} // end
// increment delta and n
$delta++;
$n++;
# end
}
} // end
return $output;
}
@ -358,31 +357,31 @@ class Requests_IDNAEncoder {
* @param int $numpoints
* @param bool $firsttime
* @return int New bias
*
* function adapt(delta,numpoints,firsttime):
*/
protected static function adapt($delta, $numpoints, $firsttime) {
# function adapt(delta,numpoints,firsttime):
# if firsttime then let delta = delta div damp
// if firsttime then let delta = delta div damp
if ($firsttime) {
$delta = floor($delta / self::BOOTSTRAP_DAMP);
}
# else let delta = delta div 2
// else let delta = delta div 2
else {
$delta = floor($delta / 2);
}
# let delta = delta + (delta div numpoints)
// let delta = delta + (delta div numpoints)
$delta += floor($delta / $numpoints);
# let k = 0
// let k = 0
$k = 0;
# while delta > ((base - tmin) * tmax) div 2 do begin
// while delta > ((base - tmin) * tmax) div 2 do begin
$max = floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN) * self::BOOTSTRAP_TMAX) / 2);
while ($delta > $max) {
# let delta = delta div (base - tmin)
// let delta = delta div (base - tmin)
$delta = floor($delta / (self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN));
# let k = k + base
// let k = k + base
$k += self::BOOTSTRAP_BASE;
# end
}
# return k + (((base - tmin + 1) * delta) div (delta + skew))
} // end
// return k + (((base - tmin + 1) * delta) div (delta + skew))
return $k + floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN + 1) * $delta) / ($delta + self::BOOTSTRAP_SKEW));
}
}
}

View file

@ -40,8 +40,8 @@ class Requests_IPv6 {
}
list($ip1, $ip2) = explode('::', $ip);
$c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':');
$c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':');
$c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':');
$c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':');
if (strpos($ip2, '.') !== false) {
$c2++;
@ -51,19 +51,19 @@ class Requests_IPv6 {
$ip = '0:0:0:0:0:0:0:0';
}
// ::xxx
else if ($c1 === -1) {
elseif ($c1 === -1) {
$fill = str_repeat('0:', 7 - $c2);
$ip = str_replace('::', $fill, $ip);
$ip = str_replace('::', $fill, $ip);
}
// xxx::
else if ($c2 === -1) {
elseif ($c2 === -1) {
$fill = str_repeat(':0', 7 - $c1);
$ip = str_replace('::', $fill, $ip);
$ip = str_replace('::', $fill, $ip);
}
// xxx::xxx
else {
$fill = ':' . str_repeat('0:', 6 - $c2 - $c1);
$ip = str_replace('::', $fill, $ip);
$ip = str_replace('::', $fill, $ip);
}
return $ip;
}
@ -84,7 +84,7 @@ class Requests_IPv6 {
*/
public static function compress($ip) {
// Prepare the IP to be compressed
$ip = self::uncompress($ip);
$ip = self::uncompress($ip);
$ip_parts = self::split_v6_v4($ip);
// Replace all leading zeros
@ -126,7 +126,7 @@ class Requests_IPv6 {
*/
protected static function split_v6_v4($ip) {
if (strpos($ip, '.') !== false) {
$pos = strrpos($ip, ':');
$pos = strrpos($ip, ':');
$ipv6_part = substr($ip, 0, $pos);
$ipv4_part = substr($ip, $pos + 1);
return array($ipv6_part, $ipv4_part);
@ -145,10 +145,10 @@ class Requests_IPv6 {
* @return bool true if $ip is a valid IPv6 address
*/
public static function check_ipv6($ip) {
$ip = self::uncompress($ip);
$ip = self::uncompress($ip);
list($ipv6, $ipv4) = self::split_v6_v4($ip);
$ipv6 = explode(':', $ipv6);
$ipv4 = explode('.', $ipv4);
$ipv6 = explode(':', $ipv6);
$ipv4 = explode('.', $ipv4);
if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) {
foreach ($ipv6 as $ipv6_part) {
// The section can't be empty

View file

@ -67,28 +67,28 @@ class Requests_IRI {
/**
* Scheme
*
* @var string
* @var string|null
*/
protected $scheme = null;
/**
* User Information
*
* @var string
* @var string|null
*/
protected $iuserinfo = null;
/**
* ihost
*
* @var string
* @var string|null
*/
protected $ihost = null;
/**
* Port
*
* @var string
* @var string|null
*/
protected $port = null;
@ -102,12 +102,12 @@ class Requests_IRI {
/**
* iquery
*
* @var string
* @var string|null
*/
protected $iquery = null;
/**
* ifragment
* ifragment|null
*
* @var string
*/
@ -118,6 +118,8 @@ class Requests_IRI {
*
* Each key is the scheme, each value is an array with each key as the IRI
* part and value as the default value for that part.
*
* @var array
*/
protected $normalization = array(
'acap' => array(
@ -249,9 +251,9 @@ class Requests_IRI {
*
* Returns false if $base is not absolute, otherwise an IRI.
*
* @param IRI|string $base (Absolute) Base IRI
* @param IRI|string $relative Relative IRI
* @return IRI|false
* @param Requests_IRI|string $base (Absolute) Base IRI
* @param Requests_IRI|string $relative Relative IRI
* @return Requests_IRI|false
*/
public static function absolutize($base, $relative) {
if (!($relative instanceof Requests_IRI)) {
@ -419,7 +421,7 @@ class Requests_IRI {
*/
protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false) {
// Normalize as many pct-encoded sections as possible
$string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string);
$string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array($this, 'remove_iunreserved_percent_encoded'), $string);
// Replace invalid percent characters
$string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
@ -1010,7 +1012,7 @@ class Requests_IRI {
/**
* Get the complete IRI
*
* @return string
* @return string|false
*/
protected function get_iri() {
if (!$this->is_valid()) {
@ -1047,7 +1049,7 @@ class Requests_IRI {
/**
* Get the complete iauthority
*
* @return string
* @return string|null
*/
protected function get_iauthority() {
if ($this->iuserinfo === null && $this->ihost === null && $this->port === null) {

View file

@ -31,5 +31,5 @@ interface Requests_Proxy {
* @see Requests_Hooks::register
* @param Requests_Hooks $hooks Hook system
*/
public function register(Requests_Hooks &$hooks);
}
public function register(Requests_Hooks $hooks);
}

View file

@ -59,12 +59,12 @@ class Requests_Proxy_HTTP implements Requests_Proxy {
$this->proxy = $args;
}
elseif (is_array($args)) {
if (count($args) == 1) {
if (count($args) === 1) {
list($this->proxy) = $args;
}
elseif (count($args) == 3) {
elseif (count($args) === 3) {
list($this->proxy, $this->user, $this->pass) = $args;
$this->use_authentication = true;
$this->use_authentication = true;
}
else {
throw new Requests_Exception('Invalid number of arguments', 'proxyhttpbadargs');
@ -82,13 +82,13 @@ class Requests_Proxy_HTTP implements Requests_Proxy {
* @see fsockopen_header
* @param Requests_Hooks $hooks Hook system
*/
public function register(Requests_Hooks &$hooks) {
$hooks->register('curl.before_send', array(&$this, 'curl_before_send'));
public function register(Requests_Hooks $hooks) {
$hooks->register('curl.before_send', array($this, 'curl_before_send'));
$hooks->register('fsockopen.remote_socket', array(&$this, 'fsockopen_remote_socket'));
$hooks->register('fsockopen.remote_host_path', array(&$this, 'fsockopen_remote_host_path'));
$hooks->register('fsockopen.remote_socket', array($this, 'fsockopen_remote_socket'));
$hooks->register('fsockopen.remote_host_path', array($this, 'fsockopen_remote_host_path'));
if ($this->use_authentication) {
$hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header'));
$hooks->register('fsockopen.after_headers', array($this, 'fsockopen_header'));
}
}
@ -148,4 +148,4 @@ class Requests_Proxy_HTTP implements Requests_Proxy {
public function get_auth_string() {
return $this->user . ':' . $this->pass;
}
}
}

View file

@ -51,6 +51,7 @@ class Requests_Response {
/**
* Protocol version, false if non-blocking
*
* @var float|boolean
*/
public $protocol_version = false;
@ -97,7 +98,7 @@ class Requests_Response {
*/
public function is_redirect() {
$code = $this->status_code;
return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400;
return in_array($code, array(300, 301, 302, 303, 307), true) || $code > 307 && $code < 400;
}
/**

View file

@ -21,7 +21,7 @@ class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictiona
* Set-Cookie headers.
*
* @param string $key
* @return string Header value
* @return string|null Header value
*/
public function offsetGet($key) {
$key = strtolower($key);
@ -58,7 +58,7 @@ class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictiona
* Get all values for a given header
*
* @param string $key
* @return array Header values
* @return array|null Header values
*/
public function getValues($key) {
$key = strtolower($key);

View file

@ -20,7 +20,6 @@ class Requests_SSL {
*
* Unfortunately, PHP doesn't check the certificate against the alternative
* names, leading things like 'https://www.github.com/' to be invalid.
* Instead
*
* @see https://tools.ietf.org/html/rfc2818#section-3.1 RFC2818, Section 3.1
*
@ -30,13 +29,6 @@ class Requests_SSL {
* @return bool
*/
public static function verify_certificate($host, $cert) {
// Calculate the valid wildcard match if the host is not an IP address
$parts = explode('.', $host);
if (ip2long($host) === false) {
$parts[0] = '*';
}
$wildcard = implode('.', $parts);
$has_dns_alt = false;
// Check the subjectAltName
@ -125,7 +117,7 @@ class Requests_SSL {
* @return boolean Does the domain match?
*/
public static function match_domain($host, $reference) {
// Check if the reference is blacklisted first
// Check if the reference is blocklisted first
if (self::verify_reference_name($reference) !== true) {
return false;
}
@ -139,7 +131,7 @@ class Requests_SSL {
// Also validates that the host has 3 parts or more, as per Firefox's
// ruleset.
if (ip2long($host) === false) {
$parts = explode('.', $host);
$parts = explode('.', $host);
$parts[0] = '*';
$wildcard = implode('.', $parts);
if ($wildcard === $reference) {
@ -149,4 +141,4 @@ class Requests_SSL {
return false;
}
}
}

View file

@ -22,12 +22,14 @@ class Requests_Session {
* Base URL for requests
*
* URLs will be made absolute using this as the base
*
* @var string|null
*/
public $url = null;
/**
* Base headers for requests
*
* @var array
*/
public $headers = array();
@ -64,9 +66,9 @@ class Requests_Session {
* @param array $options Default options for requests
*/
public function __construct($url = null, $headers = array(), $data = array(), $options = array()) {
$this->url = $url;
$this->url = $url;
$this->headers = $headers;
$this->data = $data;
$this->data = $data;
$this->options = $options;
if (empty($this->options['cookies'])) {

View file

@ -38,4 +38,4 @@ interface Requests_Transport {
* @return bool
*/
public static function test();
}
}

View file

@ -38,9 +38,9 @@ class Requests_Transport_cURL implements Requests_Transport {
public $info;
/**
* Version string
* cURL version number
*
* @var long
* @var int
*/
public $version;
@ -90,9 +90,9 @@ class Requests_Transport_cURL implements Requests_Transport {
* Constructor
*/
public function __construct() {
$curl = curl_version();
$curl = curl_version();
$this->version = $curl['version_number'];
$this->handle = curl_init();
$this->handle = curl_init();
curl_setopt($this->handle, CURLOPT_HEADER, false);
curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1);
@ -100,9 +100,11 @@ class Requests_Transport_cURL implements Requests_Transport {
curl_setopt($this->handle, CURLOPT_ENCODING, '');
}
if (defined('CURLOPT_PROTOCOLS')) {
// phpcs:ignore PHPCompatibility.Constants.NewConstants.curlopt_protocolsFound
curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
}
if (defined('CURLOPT_REDIR_PROTOCOLS')) {
// phpcs:ignore PHPCompatibility.Constants.NewConstants.curlopt_redir_protocolsFound
curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
}
}
@ -138,8 +140,8 @@ class Requests_Transport_cURL implements Requests_Transport {
$this->stream_handle = fopen($options['filename'], 'wb');
}
$this->response_data = '';
$this->response_bytes = 0;
$this->response_data = '';
$this->response_bytes = 0;
$this->response_byte_limit = false;
if ($options['max_bytes'] !== false) {
$this->response_byte_limit = $options['max_bytes'];
@ -168,7 +170,7 @@ class Requests_Transport_cURL implements Requests_Transport {
// Reset encoding and try again
curl_setopt($this->handle, CURLOPT_ENCODING, 'none');
$this->response_data = '';
$this->response_data = '';
$this->response_bytes = 0;
curl_exec($this->handle);
$response = $this->response_data;
@ -199,23 +201,24 @@ class Requests_Transport_cURL implements Requests_Transport {
$multihandle = curl_multi_init();
$subrequests = array();
$subhandles = array();
$subhandles = array();
$class = get_class($this);
foreach ($requests as $id => $request) {
$subrequests[$id] = new $class();
$subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request['url'], $request['headers'], $request['data'], $request['options']);
$subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request['url'], $request['headers'], $request['data'], $request['options']);
$request['options']['hooks']->dispatch('curl.before_multi_add', array(&$subhandles[$id]));
curl_multi_add_handle($multihandle, $subhandles[$id]);
}
$completed = 0;
$responses = array();
$completed = 0;
$responses = array();
$subrequestcount = count($subrequests);
$request['options']['hooks']->dispatch('curl.before_multi_exec', array(&$multihandle));
do {
$active = false;
$active = 0;
do {
$status = curl_multi_exec($multihandle, $active);
@ -235,15 +238,15 @@ class Requests_Transport_cURL implements Requests_Transport {
// Parse the finished requests before we start getting the new ones
foreach ($to_process as $key => $done) {
$options = $requests[$key]['options'];
if (CURLE_OK !== $done['result']) {
if ($done['result'] !== CURLE_OK) {
//get error string for handle.
$reason = curl_error($done['handle']);
$exception = new Requests_Exception_Transport_cURL(
$reason,
Requests_Exception_Transport_cURL::EASY,
$done['handle'],
$done['result']
);
$reason = curl_error($done['handle']);
$exception = new Requests_Exception_Transport_cURL(
$reason,
Requests_Exception_Transport_cURL::EASY,
$done['handle'],
$done['result']
);
$responses[$key] = $exception;
$options['hooks']->dispatch('transport.internal.parse_error', array(&$responses[$key], $requests[$key]));
}
@ -262,7 +265,7 @@ class Requests_Transport_cURL implements Requests_Transport {
$completed++;
}
}
while ($active || $completed < count($subrequests));
while ($active || $completed < $subrequestcount);
$request['options']['hooks']->dispatch('curl.after_multi_exec', array(&$multihandle));
@ -287,8 +290,8 @@ class Requests_Transport_cURL implements Requests_Transport {
$this->stream_handle = fopen($options['filename'], 'wb');
}
$this->response_data = '';
$this->response_bytes = 0;
$this->response_data = '';
$this->response_bytes = 0;
$this->response_byte_limit = false;
if ($options['max_bytes'] !== false) {
$this->response_byte_limit = $options['max_bytes'];
@ -310,17 +313,32 @@ class Requests_Transport_cURL implements Requests_Transport {
$options['hooks']->dispatch('curl.before_request', array(&$this->handle));
// Force closing the connection for old versions of cURL (<7.22).
if ( ! isset( $headers['Connection'] ) ) {
if (!isset($headers['Connection'])) {
$headers['Connection'] = 'close';
}
/**
* Add "Expect" header.
*
* By default, cURL adds a "Expect: 100-Continue" to most requests. This header can
* add as much as a second to the time it takes for cURL to perform a request. To
* prevent this, we need to set an empty "Expect" header. To match the behaviour of
* Guzzle, we'll add the empty header to requests that are smaller than 1 MB and use
* HTTP/1.1.
*
* https://curl.se/mail/lib-2017-07/0013.html
*/
if (!isset($headers['Expect']) && $options['protocol_version'] === 1.1) {
$headers['Expect'] = $this->get_expect_header($data);
}
$headers = Requests::flatten($headers);
if (!empty($data)) {
$data_format = $options['data_format'];
if ($data_format === 'query') {
$url = self::format_get($url, $data);
$url = self::format_get($url, $data);
$data = '';
}
elseif (!is_string($data)) {
@ -363,6 +381,7 @@ class Requests_Transport_cURL implements Requests_Transport {
curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout));
}
else {
// phpcs:ignore PHPCompatibility.Constants.NewConstants.curlopt_timeout_msFound
curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, round($timeout * 1000));
}
@ -370,6 +389,7 @@ class Requests_Transport_cURL implements Requests_Transport {
curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT, ceil($options['connect_timeout']));
}
else {
// phpcs:ignore PHPCompatibility.Constants.NewConstants.curlopt_connecttimeout_msFound
curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, round($options['connect_timeout'] * 1000));
}
curl_setopt($this->handle, CURLOPT_URL, $url);
@ -385,9 +405,9 @@ class Requests_Transport_cURL implements Requests_Transport {
curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
}
if (true === $options['blocking']) {
curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array(&$this, 'stream_headers'));
curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array(&$this, 'stream_body'));
if ($options['blocking'] === true) {
curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array($this, 'stream_headers'));
curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array($this, 'stream_body'));
curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE);
}
}
@ -397,7 +417,8 @@ class Requests_Transport_cURL implements Requests_Transport {
*
* @param string $response Response data from the body
* @param array $options Request options
* @return string HTTP response data including headers
* @return string|false HTTP response data including headers. False if non-blocking.
* @throws Requests_Exception
*/
public function process_response($response, $options) {
if ($options['blocking'] === false) {
@ -405,7 +426,7 @@ class Requests_Transport_cURL implements Requests_Transport {
$options['hooks']->dispatch('curl.after_request', array(&$fake_headers));
return false;
}
if ($options['filename'] !== false) {
if ($options['filename'] !== false && $this->stream_handle) {
fclose($this->stream_handle);
$this->headers = trim($this->headers);
}
@ -439,7 +460,7 @@ class Requests_Transport_cURL implements Requests_Transport {
// interim responses, such as a 100 Continue. We don't need that.
// (We may want to keep this somewhere just in case)
if ($this->done_headers) {
$this->headers = '';
$this->headers = '';
$this->done_headers = false;
}
$this->headers .= $headers;
@ -473,7 +494,7 @@ class Requests_Transport_cURL implements Requests_Transport {
if (($this->response_bytes + $data_length) > $this->response_byte_limit) {
// Limit the length
$limited_length = ($this->response_byte_limit - $this->response_bytes);
$data = substr($data, 0, $limited_length);
$data = substr($data, 0, $limited_length);
}
}
@ -497,16 +518,17 @@ class Requests_Transport_cURL implements Requests_Transport {
*/
protected static function format_get($url, $data) {
if (!empty($data)) {
$query = '';
$url_parts = parse_url($url);
if (empty($url_parts['query'])) {
$query = $url_parts['query'] = '';
$url_parts['query'] = '';
}
else {
$query = $url_parts['query'];
}
$query .= '&' . http_build_query($data, null, '&');
$query = trim($query, '&');
$query = trim($query, '&');
if (empty($url_parts['query'])) {
$url .= '?' . $query;
@ -539,4 +561,29 @@ class Requests_Transport_cURL implements Requests_Transport {
return true;
}
/**
* Get the correct "Expect" header for the given request data.
*
* @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD.
* @return string The "Expect" header.
*/
protected function get_expect_header($data) {
if (!is_array($data)) {
return strlen((string) $data) >= 1048576 ? '100-Continue' : '';
}
$bytesize = 0;
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data));
foreach ($iterator as $datum) {
$bytesize += strlen((string) $datum);
if ($bytesize >= 1048576) {
return '100-Continue';
}
}
return '';
}
}

View file

@ -62,9 +62,9 @@ class Requests_Transport_fsockopen implements Requests_Transport {
if (empty($url_parts)) {
throw new Requests_Exception('Invalid URL.', 'invalidurl', $url);
}
$host = $url_parts['host'];
$context = stream_context_create();
$verifyname = false;
$host = $url_parts['host'];
$context = stream_context_create();
$verifyname = false;
$case_insensitive_headers = new Requests_Utility_CaseInsensitiveDictionary($headers);
// HTTPS support
@ -75,13 +75,13 @@ class Requests_Transport_fsockopen implements Requests_Transport {
}
$context_options = array(
'verify_peer' => true,
// 'CN_match' => $host,
'capture_peer_cert' => true
'verify_peer' => true,
'capture_peer_cert' => true,
);
$verifyname = true;
$verifyname = true;
// SNI, if enabled (OpenSSL >=0.9.8j)
// phpcs:ignore PHPCompatibility.Constants.NewConstants.openssl_tlsext_server_nameFound
if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME) {
$context_options['SNI_enabled'] = true;
if (isset($options['verifyname']) && $options['verifyname'] === false) {
@ -91,7 +91,9 @@ class Requests_Transport_fsockopen implements Requests_Transport {
if (isset($options['verify'])) {
if ($options['verify'] === false) {
$context_options['verify_peer'] = false;
$context_options['verify_peer'] = false;
$context_options['verify_peer_name'] = false;
$verifyname = false;
}
elseif (is_string($options['verify'])) {
$context_options['cafile'] = $options['verify'];
@ -100,7 +102,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
if (isset($options['verifyname']) && $options['verifyname'] === false) {
$context_options['verify_peer_name'] = false;
$verifyname = false;
$verifyname = false;
}
stream_context_set_option($context, array('ssl' => $context_options));
@ -116,6 +118,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
}
$remote_socket .= ':' . $url_parts['port'];
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
set_error_handler(array($this, 'connect_error_handler'), E_WARNING | E_NOTICE);
$options['hooks']->dispatch('fsockopen.remote_socket', array(&$remote_socket));
@ -150,17 +153,19 @@ class Requests_Transport_fsockopen implements Requests_Transport {
$options['hooks']->dispatch('fsockopen.remote_host_path', array(&$path, $url));
$request_body = '';
$out = sprintf("%s %s HTTP/%.1f\r\n", $options['type'], $path, $options['protocol_version']);
$out = sprintf("%s %s HTTP/%.1F\r\n", $options['type'], $path, $options['protocol_version']);
if ($options['type'] !== Requests::TRACE) {
if (is_array($data)) {
$request_body = http_build_query($data, null, '&');
$request_body = http_build_query($data, '', '&');
}
else {
$request_body = $data;
}
if (!empty($data)) {
// Always include Content-length on POST requests to prevent
// 411 errors from some servers when the body is empty.
if (!empty($data) || $options['type'] === Requests::POST) {
if (!isset($case_insensitive_headers['Content-Length'])) {
$headers['Content-Length'] = strlen($request_body);
}
@ -174,7 +179,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
if (!isset($case_insensitive_headers['Host'])) {
$out .= sprintf('Host: %s', $url_parts['host']);
if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) {
if ((strtolower($url_parts['scheme']) === 'http' && $url_parts['port'] !== 80) || (strtolower($url_parts['scheme']) === 'https' && $url_parts['port'] !== 443)) {
$out .= ':' . $url_parts['port'];
}
$out .= "\r\n";
@ -192,7 +197,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
$headers = Requests::flatten($headers);
if (!empty($headers)) {
$out .= implode($headers, "\r\n") . "\r\n";
$out .= implode("\r\n", $headers) . "\r\n";
}
$options['hooks']->dispatch('fsockopen.after_headers', array(&$out));
@ -220,7 +225,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
}
$timeout_sec = (int) floor($options['timeout']);
if ($timeout_sec == $options['timeout']) {
if ($timeout_sec === $options['timeout']) {
$timeout_msec = 0;
}
else {
@ -228,11 +233,13 @@ class Requests_Transport_fsockopen implements Requests_Transport {
}
stream_set_timeout($socket, $timeout_sec, $timeout_msec);
$response = $body = $headers = '';
$response = '';
$body = '';
$headers = '';
$this->info = stream_get_meta_data($socket);
$size = 0;
$doingbody = false;
$download = false;
$size = 0;
$doingbody = false;
$download = false;
if ($options['filename']) {
$download = fopen($options['filename'], 'wb');
}
@ -248,7 +255,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
$response .= $block;
if (strpos($response, "\r\n\r\n")) {
list($headers, $block) = explode("\r\n\r\n", $response, 2);
$doingbody = true;
$doingbody = true;
}
}
@ -264,7 +271,7 @@ class Requests_Transport_fsockopen implements Requests_Transport {
if (($size + $data_length) > $this->max_bytes) {
// Limit the length
$limited_length = ($this->max_bytes - $size);
$block = substr($block, 0, $limited_length);
$block = substr($block, 0, $limited_length);
}
}
@ -300,10 +307,10 @@ class Requests_Transport_fsockopen implements Requests_Transport {
*/
public function request_multiple($requests, $options) {
$responses = array();
$class = get_class($this);
$class = get_class($this);
foreach ($requests as $id => $request) {
try {
$handler = new $class();
$handler = new $class();
$responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']);
$request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request));
@ -353,8 +360,8 @@ class Requests_Transport_fsockopen implements Requests_Transport {
$url_parts['query'] = '';
}
$url_parts['query'] .= '&' . http_build_query($data, null, '&');
$url_parts['query'] = trim($url_parts['query'], '&');
$url_parts['query'] .= '&' . http_build_query($data, '', '&');
$url_parts['query'] = trim($url_parts['query'], '&');
}
if (isset($url_parts['path'])) {
if (isset($url_parts['query'])) {

View file

@ -46,7 +46,7 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato
* Get the value for the item
*
* @param string $key Item key
* @return string Item value
* @return string|null Item value (null if offsetExists is false)
*/
public function offsetGet($key) {
$key = strtolower($key);
@ -70,7 +70,7 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato
throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
}
$key = strtolower($key);
$key = strtolower($key);
$this->data[$key] = $value;
}

View file

@ -39,7 +39,27 @@ class Requests_Utility_FilteredIterator extends ArrayIterator {
*/
public function current() {
$value = parent::current();
$value = call_user_func($this->callback, $value);
if (is_callable($this->callback)) {
$value = call_user_func($this->callback, $value);
}
return $value;
}
/**
* @inheritdoc
*/
public function unserialize($serialized) {}
/**
* @inheritdoc
*
* @phpcs:disable PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound
*/
public function __unserialize($serialized) {}
public function __wakeup() {
unset($this->callback);
}
}

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
backupGlobals="true"
bootstrap="tests/bootstrap.php"
colors="true"
verbose="true"
>
<testsuites>
<testsuite name="Authentication">
<directory suffix=".php">tests/Auth</directory>
</testsuite>
<testsuite name="Transports">
<directory suffix=".php">tests/Transport</directory>
</testsuite>
<testsuite name="Proxies">
<directory suffix=".php">tests/Proxy</directory>
</testsuite>
<testsuite name="General">
<file>tests/ChunkedEncoding.php</file>
<file>tests/Cookies.php</file>
<file>tests/Encoding.php</file>
<file>tests/IDNAEncoder.php</file>
<file>tests/IRI.php</file>
<file>tests/Requests.php</file>
<file>tests/Response/Headers.php</file>
<file>tests/Session.php</file>
<file>tests/SSL.php</file>
<file>tests/Utility/FilteredIterator.php</file>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="tests/coverage" lowUpperBound="35" highLowerBound="90"/>
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">library</directory>
</whitelist>
</filter>
</phpunit>

View file

@ -18,4 +18,11 @@ class Addon extends Entity
return $this->request('DELETE', $entityUrl . $this->id);
}
public function fetchAll($attributes = array())
{
$entityUrl = $this->getEntityUrl();
return $this->request('GET', $entityUrl , $attributes);
}
}

View file

@ -16,7 +16,7 @@ class Api
*/
public static $appsDetails = array();
const VERSION = '2.5.0';
const VERSION = '2.8.1';
/**
* @param string $key

View file

@ -7,11 +7,16 @@ use Razorpay\Api\Errors;
class Entity extends Resource implements ArrayableInterface
{
protected $attributes = array();
protected function create($attributes = null)
/**
* Create method
*
* @param array $attributes
*
*/
protected function create($attributes = null)
{
$entityUrl = $this->getEntityUrl();
return $this->request('POST', $entityUrl, $attributes);
}
@ -22,7 +27,7 @@ class Entity extends Resource implements ArrayableInterface
$this->validateIdPresence($id);
$relativeUrl = $entityUrl . $id;
return $this->request('GET', $relativeUrl);
}
@ -46,7 +51,7 @@ class Entity extends Resource implements ArrayableInterface
protected function all($options = array())
{
$entityUrl = $this->getEntityUrl();
return $this->request('GET', $entityUrl, $options);
}
@ -76,6 +81,7 @@ class Entity extends Resource implements ArrayableInterface
* @param string $method
* @param string $relativeUrl
* @param array $data
* @param array $additionHeader
*
* @return Entity
*/
@ -85,8 +91,7 @@ class Entity extends Resource implements ArrayableInterface
$response = $request->request($method, $relativeUrl, $data);
if ((isset($response['entity'])) and
($response['entity'] == $this->getEntity()))
if ((isset($response['entity'])) and ($response['entity'] == $this->getEntity()))
{
$this->fill($response);
@ -97,7 +102,7 @@ class Entity extends Resource implements ArrayableInterface
return static::buildEntity($response);
}
}
/**
* Given the JSON response of an API call, wraps it to corresponding entity
* class or a collection and returns the same.
@ -161,7 +166,9 @@ class Entity extends Resource implements ArrayableInterface
public function fill($data)
{
$attributes = array();
if(is_array($data))
{
foreach ($data as $key => $value)
{
if (is_array($value))
@ -169,7 +176,6 @@ class Entity extends Resource implements ArrayableInterface
if (static::isAssocArray($value) === false)
{
$collection = array();
foreach ($value as $v)
{
if (is_array($v))
@ -182,7 +188,6 @@ class Entity extends Resource implements ArrayableInterface
array_push($collection, $v);
}
}
$value = $collection;
}
else
@ -193,7 +198,7 @@ class Entity extends Resource implements ArrayableInterface
$attributes[$key] = $value;
}
}
$this->attributes = $attributes;
}

View file

@ -0,0 +1,34 @@
<?php
namespace Razorpay\Api;
use Requests;
class FundAccount extends Entity
{
/**
* Create a Fund Account .
*
* @param array $attributes
*
* @return FundAccount
*/
public function create($attributes = array())
{
return parent::create($attributes);
}
/**
* Fetch all Fund Accounts
*
* @param array $options
*
* @return Collection
*/
public function all($options = array())
{
return parent::all($options);
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace Razorpay\Api;
class Item extends Entity
{
public function create($attributes = array())
{
return parent::create($attributes);
}
public function fetch($id)
{
return parent::fetch($id);
}
public function edit($attributes = array())
{
$url = $this->getEntityUrl() . $this->id;
return $this->request('PATCH', $url, $attributes);
}
public function all($options = array())
{
return parent::all($options);
}
public function delete()
{
$url = $this->getEntityUrl() . $this->id;
return $this->request('DELETE', $url);
}
}

View file

@ -22,10 +22,24 @@ class Order extends Entity
return parent::all($options);
}
public function edit($attributes = array())
{
$url = $this->getEntityUrl() . $this->id;
return $this->request('PATCH', $url, $attributes);
}
public function payments()
{
$relativeUrl = $this->getEntityUrl().$this->id.'/payments';
return $this->request('GET', $relativeUrl);
}
public function transfers($options = array())
{
$relativeUrl = $this->getEntityUrl().$this->id;
return $this->request('GET', $relativeUrl, $options);
}
}

View file

@ -16,6 +16,13 @@ class Payment extends Entity
public function all($options = array())
{
if(isset($options['X-Razorpay-Account'])){
Request::addHeader('X-Razorpay-Account', $options['X-Razorpay-Account']);
unset($options['X-Razorpay-Account']);
}
return parent::all($options);
}
@ -86,4 +93,100 @@ class Payment extends Entity
return $this->request('GET', $relativeUrl);
}
public function fetchMultipleRefund($options = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/refunds';
return $this->request('GET', $relativeUrl, $options);
}
public function fetchRefund($refundId)
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/refunds/'.$refundId;
return $this->request('GET', $relativeUrl);
}
public function createRecurring($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . 'create/recurring';
return $this->request('POST', $relativeUrl, $attributes);
}
/**
* fetch Card Details
*
* @param id $id
*
* @return card
*/
public function fetchCardDetails()
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/card';
return $this->request('GET', $relativeUrl);
}
/**
* fetchPaymentDowntime
*
*/
public function fetchPaymentDowntime()
{
$relativeUrl = $this->getEntityUrl() . 'downtimes';
return $this->request('GET', $relativeUrl);
}
/**
* fetch Payment Downtime Id
*
* @param id $id
*
* @return card
*/
public function fetchPaymentDowntimeById($id)
{
$relativeUrl = $this->getEntityUrl() . 'downtimes' . $id;
return $this->request('GET', $relativeUrl);
}
/**
* create Payment Json
*
* @param array $attributes
*/
public function createPaymentJson($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . 'create/json';
return $this->request('POST', $relativeUrl, $attributes);
}
/**
* submit otp
*
* @param id $id
*
* @param array $attributes
*/
public function otpSubmit($attributes = array())
{
$relativeUrl = $this->getEntityUrl(). $this->id . '/otp/submit';
return $this->request('POST', $relativeUrl, $attributes);
}
/**
* Generate otp
*
* @param id $id
*
* @param array $attributes
*/
public function otpGenerate()
{
$relativeUrl = $this->getEntityUrl(). $this->id . '/otp_generate';
return $this->request('POST', $relativeUrl);
}
}

View file

@ -0,0 +1,88 @@
<?php
namespace Razorpay\Api;
use Requests;
class PaymentLink extends Entity
{
/**
* Creates Payment link .
*
* @param array $attributes
*
* @return PaymentLink
*/
public function create($attributes = array())
{
$attributes = json_encode($attributes);
Request::addHeader('Content-Type', 'application/json');
return parent::create($attributes);
}
/**
* Fetches Payment link entity with given id
*
* @param string $id
*
* @return PaymentLink
*/
public function fetch($id)
{
return parent::fetch($id);
}
/**
* Fetches multiple Payment link with given query options
*
* @param array $options
*
* @return Collection
*/
public function all($options = array())
{
return parent::all($options);
}
/**
* Cancels Payment link
*
* @return PaymentLink
*/
public function cancel()
{
$url = $this->getEntityUrl() . $this->id . '/cancel';
return $this->request(Requests::POST, $url);
}
public function edit($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id;
$attributes = json_encode($attributes);
Request::addHeader('Content-Type', 'application/json');
return $this->request('PATCH', $relativeUrl, $attributes);
}
/**
* Send/re-send notification with short url by given medium
*
* @param $medium - sms|email
*
* @return array
*/
public function notifyBy($medium)
{
$url = $this->getEntityUrl() . $this->id . '/notify_by/' . $medium;
$r = new Request();
return $r->request(Requests::POST, $url);
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace Razorpay\Api;
class PaymentPage extends Entity
{
public function fetch($id)
{
return parent::fetch($id);
}
public function all($options = array())
{
return parent::all($options);
}
public function activate($id)
{
$relativeUrl = $this->getEntityUrl() . $id . '/activate';
return $this->request('PATCH', $relativeUrl);
}
public function deactivate($id)
{
$relativeUrl = $this->getEntityUrl() . $id . '/deactivate';
return $this->request('PATCH', $relativeUrl);
}
}

View file

@ -0,0 +1,66 @@
<?php
namespace Razorpay\Api;
class QrCode extends Entity
{
/**
* Create QR code
* @param array $attributes
* @return Entity|QrCode
*/
public function create($attributes = array())
{
$relativeUrl = "payments/". $this->getEntityUrl() ;
return $this->request('POST', $relativeUrl, $attributes);
}
/**
* Fetch QR code details based QR id
* @param $id
* @return Entity|QrCode
*/
public function fetch($id)
{
$relativeUrl = "payments/". $this->getEntityUrl(). $id ;
return $this->request('GET', $relativeUrl);
}
/**
* Close the QR code based on id
* @return Entity|QrCode
*/
public function close()
{
$relativeUrl = "payments/{$this->getEntityUrl()}{$this->id}/close" ;
return $this->request('POST', $relativeUrl);
}
/**
* Fetch all QR code details
* @param array $options
* @return Entity|QrCode
*/
public function all($options = array())
{
$relativeUrl = "payments/". $this->getEntityUrl();
return $this->request('GET', $relativeUrl, $options);
}
/**
* Fetch payments made to a QR Code based on QR id
* @param array $options
* @return Entity|QrCode
*/
public function fetchAllPayments($options = array())
{
$relativeUrl = "payments/{$this->getEntityUrl()}{$this->id}/payments" ;
return $this->request('GET', $relativeUrl, $options);
}
}

View file

@ -21,4 +21,18 @@ class Refund extends Entity
{
return parent::all($options);
}
public function edit($attributes = array())
{
$url = $this->getEntityUrl() . $this->id;
return $this->request('PATCH', $url, $attributes);
}
public function refund($options = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/refund';
return $this->request('POST', $relativeUrl, $options);
}
}

View file

@ -26,7 +26,7 @@ class Request
* @var array
*/
protected static $headers = array(
'Razorpay-API' => 1
'Razorpay-API' => 1
);
/**
@ -34,6 +34,7 @@ class Request
* @param string $method HTTP Verb
* @param string $url Relative URL for the request
* @param array $data Data to be passed along the request
* @param array $additionHeader headers to be passed along the request
* @return array Response data in array format. Not meant
* to be used directly
*/
@ -48,16 +49,15 @@ class Request
$options = array(
'auth' => array(Api::getKey(), Api::getSecret()),
'hook' => $hooks,
'timeout' => 60,
'timeout' => 60
);
$headers = $this->getRequestHeaders();
$response = Requests::request($url, $headers, $data, $method, $options);
$response = Requests::request($url, $headers, $data, $method, $options);
$this->checkErrors($response);
return _json_decode($response->body, true);
return json_decode($response->body, true);
}
public function setCurlSslOpts($curl)
@ -96,7 +96,7 @@ class Request
try
{
$body = _json_decode($response->body, true);
$body = json_decode($response->body, true);
}
catch (Exception $e)
{
@ -157,8 +157,9 @@ class Request
{
$uaHeader = array(
'User-Agent' => $this->constructUa()
);
$headers = array_merge(self::$headers, $uaHeader);
return $headers;

View file

@ -7,9 +7,21 @@ namespace Razorpay\Api;
*/
class Settlement extends Entity
{
/**
* create Ondemand Settlemententity
* @param array $attributes
* @return Settlement
*/
public function createOndemandSettlement($attributes = array())
{
$relativeUrl = $this->getEntityUrl() ."ondemand" ;
return $this->request('POST', $relativeUrl, $attributes);
}
/**
* Fetch single settlement entity
* @param string $id
* @param string $id
* @return Settlement
*/
public function fetch($id)
@ -19,7 +31,7 @@ class Settlement extends Entity
/**
* Get all settlements according to options
* @param array $options
* @param array $options
* @return Collection
*/
public function all($options = array())
@ -38,5 +50,38 @@ class Settlement extends Entity
return $this->request('GET', $relativeUrl, $options);
}
/**
* Get Settlement Recon
* @param array $options
* @return array
*/
public function settlementRecon($options = array())
{
$relativeUrl = $this->getEntityUrl() . 'recon/combined';
return $this->request('GET', $relativeUrl, $options);
}
/**
* fetch Ondemand Settlement by Id
* @param string $id
* @return array
*/
public function fetchOndemandSettlementById()
{
$relativeUrl = $this->getEntityUrl(). "ondemand/" . $this->id ;
return $this->request('GET', $relativeUrl);
}
/**
* fetch all Ondemand Settlement
* @return array
*/
public function fetchAllOndemandSettlement()
{
$relativeUrl = $this->getEntityUrl(). "ondemand/";
return $this->request('GET', $relativeUrl);
}
}

View file

@ -32,4 +32,59 @@ class Subscription extends Entity
return $this->request('POST', $relativeUrl, $attributes);
}
/**
* Create a Registration Link
* @param array $attributes
* @return array
*/
public function createSubscriptionRegistration($attributes = array())
{
$relativeUrl = 'subscription_registration/auth_links';
return $this->request('POST', $relativeUrl, $attributes);
}
public function update($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id;
return $this->request('PATCH', $relativeUrl, $attributes);
}
public function pendingUpdate()
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/retrieve_scheduled_changes';
return $this->request('GET', $relativeUrl, null);
}
public function cancelScheduledChanges()
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/cancel_scheduled_changes';
return $this->request('POST', $relativeUrl, null);
}
public function pause($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id.'/pause';
return $this->request('POST', $relativeUrl, $attributes);
}
public function resume($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id.'/resume';
return $this->request('POST', $relativeUrl, $attributes);
}
public function deleteOffer($offerId)
{
$relativeUrl = $this->getEntityUrl() . $this->id.'/'.$offerId;
return $this->request('DELETE', $relativeUrl);
}
}

View file

@ -24,10 +24,20 @@ class Utility
$payload = $paymentId . '|' . $subscriptionId;
}
else if (isset($attributes['razorpay_payment_link_id']) === true)
{
$paymentLinkId = $attributes['razorpay_payment_link_id'];
$paymentLinkRefId = $attributes['razorpay_payment_link_reference_id'];
$paymentLinkStatus = $attributes['razorpay_payment_link_status'];
$payload = $paymentLinkId . '|'. $paymentLinkRefId . '|' . $paymentLinkStatus . '|' . $paymentId;
}
else
{
throw new Errors\SignatureVerificationError(
'Either razorpay_order_id or razorpay_subscription_id must be present.');
'Either razorpay_order_id or razorpay_subscription_id or razorpay_payment_link_id must be present.');
}
$secret = Api::getSecret();

View file

@ -21,19 +21,37 @@ class VirtualAccount extends Entity
public function close()
{
$relativeUrl = $this->getEntityUrl() . $this->id;
$relativeUrl = $this->getEntityUrl() . $this->id . '/close';
$data = array(
'status' => 'closed'
);
return $this->request('PATCH', $relativeUrl, $data);
return $this->request('POST', $relativeUrl);
}
public function payments()
public function payments($options = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/payments';
return $this->request('GET', $relativeUrl);
return $this->request('GET', $relativeUrl, $options);
}
public function addReceiver($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/receivers';
return $this->request('POST', $relativeUrl, $attributes);
}
public function addAllowedPayer($attributes = array())
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/allowed_payers';
return $this->request('POST', $relativeUrl, $attributes);
}
public function deleteAllowedPayer($allowedPlayerId)
{
$relativeUrl = $this->getEntityUrl() . $this->id . '/allowed_payers/'.$allowedPlayerId;
return $this->request('DELETE', $relativeUrl);
}
}

View file

@ -0,0 +1,39 @@
<?php
namespace Razorpay\Api;
use Requests;
class Webhook extends Entity
{
/**
* @param $id webhook id description
*/
public function create($attributes = array())
{
return parent::create($attributes);
}
public function fetch($id)
{
return parent::fetch($id);
}
public function all($options = array())
{
return parent::all($options);
}
/**
* Patches given webhook with new attributes
*
* @param array $attributes
*
* @return Webhooks
*/
public function edit($attributes = array(), $id)
{
$url = $this->getEntityUrl() . $id;
return $this->request(Requests::PUT, $url, $attributes);
}
}

View file

@ -1 +1 @@
2.5.0
2.8.1

View file

@ -15,6 +15,8 @@ use Aws\AwsClient;
* @method \GuzzleHttp\Promise\Promise createBackendAuthAsync(array $args = [])
* @method \Aws\Result createBackendConfig(array $args = [])
* @method \GuzzleHttp\Promise\Promise createBackendConfigAsync(array $args = [])
* @method \Aws\Result createBackendStorage(array $args = [])
* @method \GuzzleHttp\Promise\Promise createBackendStorageAsync(array $args = [])
* @method \Aws\Result createToken(array $args = [])
* @method \GuzzleHttp\Promise\Promise createTokenAsync(array $args = [])
* @method \Aws\Result deleteBackend(array $args = [])
@ -23,6 +25,8 @@ use Aws\AwsClient;
* @method \GuzzleHttp\Promise\Promise deleteBackendAPIAsync(array $args = [])
* @method \Aws\Result deleteBackendAuth(array $args = [])
* @method \GuzzleHttp\Promise\Promise deleteBackendAuthAsync(array $args = [])
* @method \Aws\Result deleteBackendStorage(array $args = [])
* @method \GuzzleHttp\Promise\Promise deleteBackendStorageAsync(array $args = [])
* @method \Aws\Result deleteToken(array $args = [])
* @method \GuzzleHttp\Promise\Promise deleteTokenAsync(array $args = [])
* @method \Aws\Result generateBackendAPIModels(array $args = [])
@ -37,12 +41,18 @@ use Aws\AwsClient;
* @method \GuzzleHttp\Promise\Promise getBackendAuthAsync(array $args = [])
* @method \Aws\Result getBackendJob(array $args = [])
* @method \GuzzleHttp\Promise\Promise getBackendJobAsync(array $args = [])
* @method \Aws\Result getBackendStorage(array $args = [])
* @method \GuzzleHttp\Promise\Promise getBackendStorageAsync(array $args = [])
* @method \Aws\Result getToken(array $args = [])
* @method \GuzzleHttp\Promise\Promise getTokenAsync(array $args = [])
* @method \Aws\Result importBackendAuth(array $args = [])
* @method \GuzzleHttp\Promise\Promise importBackendAuthAsync(array $args = [])
* @method \Aws\Result importBackendStorage(array $args = [])
* @method \GuzzleHttp\Promise\Promise importBackendStorageAsync(array $args = [])
* @method \Aws\Result listBackendJobs(array $args = [])
* @method \GuzzleHttp\Promise\Promise listBackendJobsAsync(array $args = [])
* @method \Aws\Result listS3Buckets(array $args = [])
* @method \GuzzleHttp\Promise\Promise listS3BucketsAsync(array $args = [])
* @method \Aws\Result removeAllBackends(array $args = [])
* @method \GuzzleHttp\Promise\Promise removeAllBackendsAsync(array $args = [])
* @method \Aws\Result removeBackendConfig(array $args = [])
@ -55,5 +65,7 @@ use Aws\AwsClient;
* @method \GuzzleHttp\Promise\Promise updateBackendConfigAsync(array $args = [])
* @method \Aws\Result updateBackendJob(array $args = [])
* @method \GuzzleHttp\Promise\Promise updateBackendJobAsync(array $args = [])
* @method \Aws\Result updateBackendStorage(array $args = [])
* @method \GuzzleHttp\Promise\Promise updateBackendStorageAsync(array $args = [])
*/
class AmplifyBackendClient extends AwsClient {}

View file

@ -0,0 +1,37 @@
<?php
namespace Aws\AmplifyUIBuilder;
use Aws\AwsClient;
/**
* This client is used to interact with the **AWS Amplify UI Builder** service.
* @method \Aws\Result createComponent(array $args = [])
* @method \GuzzleHttp\Promise\Promise createComponentAsync(array $args = [])
* @method \Aws\Result createTheme(array $args = [])
* @method \GuzzleHttp\Promise\Promise createThemeAsync(array $args = [])
* @method \Aws\Result deleteComponent(array $args = [])
* @method \GuzzleHttp\Promise\Promise deleteComponentAsync(array $args = [])
* @method \Aws\Result deleteTheme(array $args = [])
* @method \GuzzleHttp\Promise\Promise deleteThemeAsync(array $args = [])
* @method \Aws\Result exchangeCodeForToken(array $args = [])
* @method \GuzzleHttp\Promise\Promise exchangeCodeForTokenAsync(array $args = [])
* @method \Aws\Result exportComponents(array $args = [])
* @method \GuzzleHttp\Promise\Promise exportComponentsAsync(array $args = [])
* @method \Aws\Result exportThemes(array $args = [])
* @method \GuzzleHttp\Promise\Promise exportThemesAsync(array $args = [])
* @method \Aws\Result getComponent(array $args = [])
* @method \GuzzleHttp\Promise\Promise getComponentAsync(array $args = [])
* @method \Aws\Result getTheme(array $args = [])
* @method \GuzzleHttp\Promise\Promise getThemeAsync(array $args = [])
* @method \Aws\Result listComponents(array $args = [])
* @method \GuzzleHttp\Promise\Promise listComponentsAsync(array $args = [])
* @method \Aws\Result listThemes(array $args = [])
* @method \GuzzleHttp\Promise\Promise listThemesAsync(array $args = [])
* @method \Aws\Result refreshToken(array $args = [])
* @method \GuzzleHttp\Promise\Promise refreshTokenAsync(array $args = [])
* @method \Aws\Result updateComponent(array $args = [])
* @method \GuzzleHttp\Promise\Promise updateComponentAsync(array $args = [])
* @method \Aws\Result updateTheme(array $args = [])
* @method \GuzzleHttp\Promise\Promise updateThemeAsync(array $args = [])
*/
class AmplifyUIBuilderClient extends AwsClient {}

View file

@ -0,0 +1,9 @@
<?php
namespace Aws\AmplifyUIBuilder\Exception;
use Aws\Exception\AwsException;
/**
* Represents an error interacting with the **AWS Amplify UI Builder** service.
*/
class AmplifyUIBuilderException extends AwsException {}

View file

@ -172,6 +172,7 @@ class DecodingEventStreamIterator implements Iterator
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->currentEvent;
@ -180,11 +181,13 @@ class DecodingEventStreamIterator implements Iterator
/**
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->key;
}
#[\ReturnTypeWillChange]
public function next()
{
$this->currentPosition = $this->stream->tell();
@ -194,6 +197,7 @@ class DecodingEventStreamIterator implements Iterator
}
}
#[\ReturnTypeWillChange]
public function rewind()
{
$this->stream->rewind();
@ -205,6 +209,7 @@ class DecodingEventStreamIterator implements Iterator
/**
* @return bool
*/
#[\ReturnTypeWillChange]
public function valid()
{
return $this->currentPosition < $this->stream->getSize();

View file

@ -33,26 +33,31 @@ class EventParsingIterator implements Iterator
$this->parser = $parser;
}
#[\ReturnTypeWillChange]
public function current()
{
return $this->parseEvent($this->decodingIterator->current());
}
#[\ReturnTypeWillChange]
public function key()
{
return $this->decodingIterator->key();
}
#[\ReturnTypeWillChange]
public function next()
{
$this->decodingIterator->next();
}
#[\ReturnTypeWillChange]
public function rewind()
{
$this->decodingIterator->rewind();
}
#[\ReturnTypeWillChange]
public function valid()
{
return $this->decodingIterator->valid();

View file

@ -0,0 +1,13 @@
<?php
namespace Aws\AppConfigData;
use Aws\AwsClient;
/**
* This client is used to interact with the **AWS AppConfig Data** service.
* @method \Aws\Result getLatestConfiguration(array $args = [])
* @method \GuzzleHttp\Promise\Promise getLatestConfigurationAsync(array $args = [])
* @method \Aws\Result startConfigurationSession(array $args = [])
* @method \GuzzleHttp\Promise\Promise startConfigurationSessionAsync(array $args = [])
*/
class AppConfigDataClient extends AwsClient {}

Some files were not shown because too many files have changed in this diff Show more