add getContentType method
authorgggeek <giunta.gaetano@gmail.com>
Thu, 2 Feb 2023 12:53:57 +0000 (12:53 +0000)
committergggeek <giunta.gaetano@gmail.com>
Thu, 2 Feb 2023 12:53:57 +0000 (12:53 +0000)
NEWS.md
src/Client.php
src/Server.php
src/Traits/PayloadBearer.php

diff --git a/NEWS.md b/NEWS.md
index 60f1cfa..fb70d32 100644 (file)
--- 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()`
index 38a913c..9fa488e 100644 (file)
@@ -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';
index 2da4258..0915e45 100644 (file)
@@ -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");
 
index 555baf8..877009f 100644 (file)
@@ -34,4 +34,12 @@ trait PayloadBearer
     {
         return $this->payload;
     }
+
+    /**
+     * @return string
+     */
+    public function getContentType()
+    {
+        return $this->content_type;
+    }
 }