Date Published: January 15, 2024
Drupal throwing status code 400 and BadRequestHttpException when using Google Data Saver
Issue¶
- Visiting some/all pages show "A client error has occurred"
- Watchdog log contains errors similar to this:
... Symfony\Component\HttpKernel\Exception\BadRequestHttpException:
The request has both a trusted "FORWARDED" header and a trusted
"X_FORWARDED_FOR" header, conflicting with each other. You should
either configure your proxy to remove one of them, or configure
your project to distrust the offending one. in Symfony\Component
\HttpKernel\HttpKernel->handle() (line XX of /mnt/www/html/
[sitename]/vendor/symfony/http-kernel/HttpKernel.php) ...
This issue has been reproduced with the following steps when a Drupal site exhibits the problem:
- Clear Drupal cache
- Visit site without the Google Data Saver extension enabled, confirm a page is a HTTP status 200
- Enable the Data Saver extension
- Clear Drupal cache again
- Visit site again; page status code should be a 400 Bad Request (You can see this in the browser inspector)
Affected Applications/Limitations¶
This issue stems from a combination of:
- Having a recent update of Drupal (and the Symfony components)
- Incoming requests from a web browser (desktop or mobile) using Google Data Compression (https://cloud.google.com/web-risk/docs/compression)
- With the results of the problem potentially ending up cached in Drupal's internal cache for other browsers (regardless of them using the Google Compression proxy or not).
This issue was handled in the Symfony project here: https://github.com/symfony/symfony/issues/20215
Resolution¶
You can do either of the following actions:
Did not find what you were looking for?
If this content did not answer your questions, try searching or contacting our support team for further assistance.