Skip to content

Commit

Permalink
[2.x] Use HTTP/3 if possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Apr 10, 2024
1 parent 8905257 commit 1dee9fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=Laragear_ReCaptcha&metric=alert_status)](https://sonarcloud.io/dashboard?id=Laragear_ReCaptcha)
[![Laravel Octane Compatibility](https://img.shields.io/badge/Laravel%20Octane-Compatible-success?style=flat&logo=laravel)](https://laravel.com/docs/11.x/octane#introduction)

Integrate reCAPTCHA using **async HTTP/2**, making your app **fast** with a few lines.
Integrate reCAPTCHA using **async HTTP/3**, making your app **fast** with a few lines.

```php
use Illuminate\Support\Facades\Route;
Expand Down Expand Up @@ -449,14 +449,14 @@ This also control how many minutes to set the "remember". You can set `INF` cons
```php
return [
'client' => [
'version' => 2.0,
'version' => 4.0,
],
];
```

This array sets the options for the outgoing request to reCAPTCHA servers. [This is handled by Guzzle](https://docs.guzzlephp.org/en/stable/request-options.html), which in turn will pass it to the underlying transport. Depending on your system, it will probably be cURL.

By default, it instructs Guzzle to use HTTP/2 whenever possible.
By default, it instructs Guzzle to use HTTP/3 whenever possible.

### Credentials

Expand Down Expand Up @@ -554,9 +554,11 @@ The file gets published into the `.stubs` folder of your project, while the meta

There should be no problems using this package with Laravel Octane as intended.

## HTTP/3
## HTTP/3 and cURL

To use HTTP/3, [ensure you're using PHP 8.2 or later](https://php.watch/articles/php-curl-http3). cURL version [7.83.0](https://curl.se/changes.html#7_83_0) supports (stable) HTTP/3, and latest PHP 8.2 uses version 7.85.

Currently, HTTP/3 is [still on draft state](https://datatracker.ietf.org/doc/draft-ietf-quic-http/). Until it's [Internet Standard](https://en.wikipedia.org/wiki/Internet_Standard), cURL and Guzzle and reCAPTCHA servers must implement the finished state of the protocol, which as of today is still a moving target.
For more information about checking if your platform can make HTTP/3 requests, check this [PHP Watch article](https://php.watch/articles/php-curl-http3).

## Security

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "laragear/recaptcha",
"description": "Integrate reCAPTCHA using async HTTP/2, making your app fast with a few lines.",
"description": "Integrate reCAPTCHA using async HTTP/3, making your app fast with a few lines.",
"type": "library",
"license": "MIT",
"minimum-stability": "dev",
Expand All @@ -9,7 +9,9 @@
"laragear",
"captcha",
"recaptcha",
"google"
"google",
"http2",
"http3"
],
"authors": [
{
Expand Down
5 changes: 3 additions & 2 deletions config/recaptcha.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use GuzzleHttp\RequestOptions;
use Laragear\ReCaptcha\ReCaptcha;

return [
Expand Down Expand Up @@ -83,14 +84,14 @@
|--------------------------------------------------------------------------
|
| This array is passed down to the underlying HTTP Client which will make
| the request to reCAPTCHA servers. By default, is set to use HTTP/2 for
| the request to reCAPTCHA servers. By default, is set to use HTTP/3 for
| the request. You can change, remove or add more options in the array.
|
| @see https://docs.guzzlephp.org/en/stable/request-options.html
*/

'client' => [
'version' => 2.0,
RequestOptions::VERSION => 3.0,
],

/*
Expand Down

0 comments on commit 1dee9fb

Please sign in to comment.