mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 03:34:33 +02:00
Set a default user-agent header in WireHttp to resolve issues where accessed hostname seems to require it (noticed this on a couple hosts running Varnish, which seem to throw a 400/403 if no user-agent header present)
This commit is contained in:
@@ -467,6 +467,13 @@ class WireHttp extends Wire {
|
||||
|
||||
if(!empty($data)) $this->setData($data);
|
||||
|
||||
if(!isset($this->headers['user-agent'])) {
|
||||
// some web servers deliver a 400 error if no user-agent set in request header, so make sure one is set
|
||||
$this->setHeader('user-agent',
|
||||
'ProcessWire/' . ProcessWire::versionMajor . '.' . ProcessWire::versionMinor . ' (' . $this->className() . ')'
|
||||
);
|
||||
}
|
||||
|
||||
if(!in_array(strtoupper($method), $this->allowHttpMethods)) $method = 'POST';
|
||||
|
||||
if(!$this->hasFopen || strpos($url, 'https://') === 0 && !extension_loaded('openssl')) {
|
||||
|
Reference in New Issue
Block a user