1
0
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:
Michael Dowling 2013-01-23 10:41:18 -08:00
parent 53260156a5
commit f0f597ec1c
2 changed files with 4 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}