mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 18:43:22 +01:00
Not overwriting JSON or XML request content-type headers if one is set
This commit is contained in:
parent
53260156a5
commit
f0f597ec1c
@ -63,7 +63,8 @@ class JsonVisitor extends AbstractRequestVisitor
|
||||
$json = $this->data[$command];
|
||||
unset($this->data[$command]);
|
||||
$request->setBody(json_encode($json));
|
||||
if ($this->jsonContentType) {
|
||||
// Don't overwrite the Content-Type if one is set
|
||||
if ($this->jsonContentType && !$request->hasHeader('Content-Type')) {
|
||||
$request->setHeader('Content-Type', $this->jsonContentType);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,8 @@ class XmlVisitor extends AbstractRequestVisitor
|
||||
$xml = $this->data[$command];
|
||||
unset($this->data[$command]);
|
||||
$request->setBody($xml->asXML());
|
||||
if ($this->contentType) {
|
||||
// Don't overwrite the Content-Type if one is set
|
||||
if ($this->contentType && !$request->hasHeader('Content-Type')) {
|
||||
$request->setHeader('Content-Type', $this->contentType);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user