Updated RemoteObject to handle extra headers differently.
This commit is contained in:
parent
51c1f4b481
commit
e7f8e0e779
@ -65,7 +65,7 @@ class RemoteObject extends Object {
|
|||||||
* serve as a good indicator that the object does not have all
|
* serve as a good indicator that the object does not have all
|
||||||
* attributes set.
|
* attributes set.
|
||||||
*/
|
*/
|
||||||
protected $allHeaders;
|
protected $allHeaders = array();
|
||||||
|
|
||||||
protected $cdnUrl;
|
protected $cdnUrl;
|
||||||
protected $cdnSslUrl;
|
protected $cdnSslUrl;
|
||||||
@ -285,16 +285,41 @@ class RemoteObject extends Object {
|
|||||||
return $this->allHeaders;
|
return $this->allHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function additionalHeaders() {
|
public function additionalHeaders($mergeAll = FALSE) {
|
||||||
// Any additional headers will be set. Note that $this->headers will contain
|
// Any additional headers will be set. Note that $this->headers will contain
|
||||||
// some headers that are NOT additional. But we do not know which headers are
|
// some headers that are NOT additional. But we do not know which headers are
|
||||||
// additional and which are from Swift because Swift does not commit to using
|
// additional and which are from Swift because Swift does not commit to using
|
||||||
// a specific set of headers.
|
// a specific set of headers.
|
||||||
$additionalHeaders = parent::additionalHeaders() + $this->headers;
|
if ($mergeAll) {
|
||||||
|
$additionalHeaders = parent::additionalHeaders() + $this->allHeaders;
|
||||||
|
$this->filterHeaders($additionalHeaders);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$additionalHeaders = parent::additionalHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
return $additionalHeaders;
|
return $additionalHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected $reservedHeaders = array(
|
||||||
|
'etag' => TRUE, 'content-length' => TRUE,
|
||||||
|
'x-auth-token' => TRUE,
|
||||||
|
'transfer-encoding' => TRUE,
|
||||||
|
'x-trans-id' => TRUE,
|
||||||
|
);
|
||||||
|
public function filterHeaders(&$headers) {
|
||||||
|
$unset = array();
|
||||||
|
foreach ($headers as $name => $value) {
|
||||||
|
$lower = strtolower($name);
|
||||||
|
if (isset($this->reservedHeaders[$lower])) {
|
||||||
|
$unset[] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($unset as $u) {
|
||||||
|
unset($headers[$u]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an array of header names.
|
* Given an array of header names.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user