Skip to content
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

Do not respond with 200 OK if proxied request fails #41

Open
avbentem opened this issue Dec 23, 2020 · 0 comments
Open

Do not respond with 200 OK if proxied request fails #41

avbentem opened this issue Dec 23, 2020 · 0 comments

Comments

@avbentem
Copy link

Currently fatal errors such as invalid domains simply return 200 OK. To mitigate that one could, e.g., throw 502 Bad Gateway instead.

Change:

// retrieve response (headers and content)
$response = curl_exec($ch);
curl_close($ch);

...into:

// retrieve response (headers and content)
$response = curl_exec($ch);
if ($response === false) {
    http_response_code(502);
    echo 'Failed to proxy to ' . $request_url . ': ' . curl_error($ch);
    curl_close($ch);
    exit();
}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant