Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
extensions: 'json'
cache-version: '1'
composer-version: 'v1'
composer-version: 'v2'
composer-install: 'composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable'

jobs:
Expand All @@ -21,13 +21,13 @@ jobs:

strategy:
matrix:
php-version: [ '8.1', '8.2' ]
php-version: [ '8.1', '8.2', '8.3', '8.4' ]
operating-system: [ 'ubuntu-latest' ]
fail-fast: false

steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'
uses: 'actions/checkout@v4'

- name: 'Setup PHP cache environment'
id: 'extcache'
Expand All @@ -38,7 +38,7 @@ jobs:
key: '${{ env.cache-version }}'

- name: 'Cache PHP extensions'
uses: 'actions/cache@v2'
uses: 'actions/cache@v4'
with:
path: '${{ steps.extcache.outputs.dir }}'
key: '${{ steps.extcache.outputs.key }}'
Expand All @@ -56,10 +56,10 @@ jobs:

- name: 'Get Composer cache directory'
id: 'composercache'
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: 'Cache PHP dependencies'
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: '${{ steps.composercache.outputs.dir }}'
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -80,13 +80,13 @@ jobs:

strategy:
matrix:
php-version: [ '8.1', '8.2' ]
php-version: [ '8.1', '8.2', '8.3', '8.4' ]
operating-system: [ 'ubuntu-latest' ]
fail-fast: false

steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'
uses: 'actions/checkout@v4'

- name: 'Setup PHP cache environment'
id: 'extcache'
Expand All @@ -97,7 +97,7 @@ jobs:
key: '${{ env.cache-version }}'

- name: 'Cache PHP extensions'
uses: 'actions/cache@v2'
uses: 'actions/cache@v4'
with:
path: '${{ steps.extcache.outputs.dir }}'
key: '${{ steps.extcache.outputs.key }}'
Expand All @@ -115,10 +115,10 @@ jobs:

- name: 'Get Composer cache directory'
id: 'composercache'
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: 'Cache PHP dependencies'
uses: 'actions/cache@v2'
uses: 'actions/cache@v4'
with:
path: '${{ steps.composercache.outputs.dir }}'
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -136,15 +136,14 @@ jobs:

strategy:
matrix:
php-version: [ '8.1', '8.2' ]
php-version: [ '8.1', '8.2', '8.3', '8.4' ]
operating-system: [ 'ubuntu-latest' ]
composer-args: [ '' ]

fail-fast: false

steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'
uses: 'actions/checkout@v4'

- name: 'Setup PHP cache environment'
id: 'extcache'
Expand All @@ -155,7 +154,7 @@ jobs:
key: '${{ env.cache-version }}'

- name: 'Cache PHP extensions'
uses: 'actions/cache@v2'
uses: 'actions/cache@v4'
with:
path: '${{ steps.extcache.outputs.dir }}'
key: '${{ steps.extcache.outputs.key }}'
Expand All @@ -173,10 +172,10 @@ jobs:

- name: 'Get Composer cache directory'
id: 'composercache'
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: 'Cache PHP dependencies'
uses: 'actions/cache@v2'
uses: 'actions/cache@v4'
with:
path: '${{ steps.composercache.outputs.dir }}'
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -194,15 +193,15 @@ jobs:

strategy:
matrix:
php-version: [ '8.1', '8.2' ]
php-version: [ '8.1', '8.2', '8.3', '8.4' ]
operating-system: [ 'ubuntu-latest' ]
fail-fast: false

if: "github.event_name == 'push'"

steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'
uses: 'actions/checkout@v4'

- name: 'Setup PHP cache environment'
id: 'extcache'
Expand All @@ -213,7 +212,7 @@ jobs:
key: '${{ env.cache-version }}'

- name: 'Cache PHP extensions'
uses: 'actions/cache@v2'
uses: 'actions/cache@v4'
with:
path: '${{ steps.extcache.outputs.dir }}'
key: '${{ steps.extcache.outputs.key }}'
Expand All @@ -231,10 +230,10 @@ jobs:

- name: 'Get Composer cache directory'
id: 'composercache'
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: 'Cache PHP dependencies'
uses: 'actions/cache@v2'
uses: 'actions/cache@v4'
with:
path: '${{ steps.composercache.outputs.dir }}'
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -246,7 +245,7 @@ jobs:
- name: 'Tests'
run: vendor/bin/tester tests -C --coverage coverage.xml --coverage-src src

- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
14 changes: 14 additions & 0 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ $httpRequest = HttpRequest::from('https://www.example.com/', HttpMethod::GET, [
]);
```

Option `verify` can be set by boolean value or by specifying path to accepted certificate file.

```php
$httpRequest = HttpRequest::from('https://www.example.com/', HttpMethod::GET, [
'verify' => false,
]);
```

```php
$httpRequest = HttpRequest::from('https://www.example.com/', HttpMethod::GET, [
'verify' => 'path/to/some/accepted/certificate.crt',
]);
```

## Redirects


Expand Down
10 changes: 8 additions & 2 deletions src/Fapi/HttpClient/GuzzleHttpClient.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,14 @@ private function processOptions(RequestInterface $request): array
$options['connect_timeout'] = (int) ($headerLine !== '' ? $headerLine : 5);
}

if ($request->hasHeader('verify') && !(bool) $request->getHeaderLine('verify')) {
$options['verify'] = false;
if ($request->hasHeader('verify')) {
$headerLine = $request->getHeaderLine('verify');

$options['verify'] = match ($headerLine) {
'false', '' => false,
'true', '1' => true,
default => $headerLine,
};
}

if ($request->hasHeader('cert')) {
Expand Down
12 changes: 9 additions & 3 deletions src/Fapi/HttpClient/HttpRequest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ private static function preProcessHeaders(array $options, StreamInterface|string
if (isset($options['verify'])) {
$value = $options['verify'];
self::validateVerify($value);
$data['verify'] = (bool) $value;
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
}

$data['verify'] = $value;
}

if (isset($options['cert'])) {
Expand Down Expand Up @@ -211,8 +215,10 @@ private static function validateConnectTimeoutOption(mixed $connectTimeout): voi

private static function validateVerify(mixed $verify): void
{
if (!is_bool($verify)) {
throw new InvalidArgumentException('Option verify must be an bool.');
if (!(is_bool($verify) || (is_string($verify) && file_exists($verify)))) {
throw new InvalidArgumentException(
'Option verify must be an bool or a string path to file, ' . $verify . ' given.',
);
}
}

Expand Down
Loading