Skip to content

Http Proxy support #573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -145,3 +145,12 @@ project](https://cloud.google.com/appengine/docs/flexible/php/download).

No one ever has enough engineers, so we're very happy to accept contributions
via Pull Requests. For details, see [CONTRIBUTING](CONTRIBUTING.md)

## Proxy support
To make requests to Google servers via proxy add environment variable
RECAPTCHA_PROXY with proxy address and port.
Exampple:
```
RECAPTCHA_PROXY=192.168.1.100:3128
```
Use CurlPost RequestMethod.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "google/recaptcha",
"name": "jakreiter/recaptchaproxyable",
"description": "Client library for reCAPTCHA, a free service that protects websites from spam and abuse.",
"type": "library",
"keywords": ["recaptcha", "captcha", "spam", "abuse"],
4 changes: 4 additions & 0 deletions src/ReCaptcha/RequestMethod/CurlPost.php
Original file line number Diff line number Diff line change
@@ -90,6 +90,10 @@ public function submit(RequestParameters $params)
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true
);
// jakrei - added proxy support
if (isset($_ENV['RECAPTCHA_PROXY']) && $_ENV['RECAPTCHA_PROXY']) {
$options[CURLOPT_PROXY] = $_ENV['RECAPTCHA_PROXY'];
}
$this->curl->setoptArray($handle, $options);

$response = $this->curl->exec($handle);