Subject: Re: bug#32983: 27.0.50; soap-client shall accept "multipart/related" Content-type

From: Michael Albinus <[email-masked]>
Date: Mon, 08 Oct 2018 11:07:44 +0200

Michael Albinus <[email-masked]> writes:

> The soap-client checks HTTPS responses for a proper Content-type
> "text/xml". However, not all SOAP servers return this. For example, the
> Perl SOAP::Lite module returns sometimes the Content-type
> "multipart/related". As an example one could load the GNU ELPA package
> debbugs, and eval the form (debbugs-get-bug-log 25235)
>
> This shall be supported by soap-client.

The following patch works for me. Shall be reviewed by the soap-client
maintainers.

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el
index f5de05dc3d..5c819636e6 100644
--- a/lisp/net/soap-client.el
+++ b/lisp/net/soap-client.el
@@ -2337,6 +2337,14 @@ soap-wsdl-resolve-references
 (defun soap-parse-server-response ()
   "Error-check and parse the XML contents of the current buffer."
   (let ((mime-part (mm-dissect-buffer t t)))
+    (when (and
+           (equal (mm-handle-media-type mime-part) "multipart/related")
+           (equal (get-text-property 0 'type (mm-handle-media-type mime-part))
+                  "text/xml"))
+      (setq mime-part
+            (mm-make-handle
+             (get-text-property 0 'buffer (mm-handle-media-type mime-part))
+             `(,(get-text-property 0 'type (mm-handle-media-type mime-part))))))
     (unless mime-part
       (error "Failed to decode response from server"))
     (unless (equal (car (mm-handle-type mime-part)) "text/xml")
--8<---------------cut here---------------end--------------->8---