From ebef44e252e114896ff0aeb7df20f12e87f59a68 Mon Sep 17 00:00:00 2001 From: gggeek Date: Thu, 2 Feb 2023 12:53:57 +0000 Subject: [PATCH] add getContentType method --- NEWS.md | 2 ++ src/Client.php | 4 ++-- src/Server.php | 2 +- src/Traits/PayloadBearer.php | 8 ++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 60f1cfae..fb70d327 100644 --- a/NEWS.md +++ b/NEWS.md @@ -70,6 +70,8 @@ * new: method `PhpXmlRpc::useInteropFaults()` can be used to make the library change the error codes it generates to match the spec described at https://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php +* new: both `Request` and `Response` acquired methods `getPayload` and `getContentType` + * new: method `Client::getUrl()` * new: method `Server::setDispatchMap()` diff --git a/src/Client.php b/src/Client.php index 38a913c7..9fa488e0 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1175,7 +1175,7 @@ class Client $encodingHdr . 'Accept-Charset: ' . implode(',', $opts['accepted_charset_encodings']) . "\r\n" . $cookieHeader . - 'Content-Type: ' . $req->content_type . "\r\nContent-Length: " . + 'Content-Type: ' . $req->getContentType() . "\r\nContent-Length: " . strlen($payload) . "\r\n\r\n" . $payload; @@ -1438,7 +1438,7 @@ class Client } } // extra headers - $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $opts['accepted_charset_encodings'])); + $headers = array('Content-Type: ' . $req->getContentType(), 'Accept-Charset: ' . implode(',', $opts['accepted_charset_encodings'])); // if no keepalive is wanted, let the server know it in advance if (!$opts['keepalive']) { $headers[] = 'Connection: close'; diff --git a/src/Server.php b/src/Server.php index 2da4258b..0915e452 100644 --- a/src/Server.php +++ b/src/Server.php @@ -420,7 +420,7 @@ class Server // if we get a warning/error that has output some text before here, then we cannot // add a new header. We cannot say we are sending xml, either... if (!headers_sent()) { - header('Content-Type: ' . $resp->content_type); + header('Content-Type: ' . $resp->getContentType()); // we do not know if client actually told us an accepted charset, but if it did we have to tell it what we did header("Vary: Accept-Charset"); diff --git a/src/Traits/PayloadBearer.php b/src/Traits/PayloadBearer.php index 555baf81..877009f8 100644 --- a/src/Traits/PayloadBearer.php +++ b/src/Traits/PayloadBearer.php @@ -34,4 +34,12 @@ trait PayloadBearer { return $this->payload; } + + /** + * @return string + */ + public function getContentType() + { + return $this->content_type; + } } -- 2.47.0