Hi Guilers, I’m having a problem with http-post and I think it might be a bug. I’m talking to a Debbugs SOAP service over HTTP by sending (via POST) an XML request. The Debbugs SOAP service responds with a string of XML.
Here’s a simplified version of what I do: (use-module (web http)) (let ((req-xml "<soap:Envelope xmlns:soap...>")) (receive (response body) (http-post uri #:body req-xml #:headers `((content-type . (text/xml)) (content-length . ,(string-length req-xml)))) ;; Do something with the response body (xml->sxml body #:trim-whitespace? #t))) This fails for some requests with an error like this: web/http.scm:1609:23: Bad Content-Type header: multipart/related; type="text/xml"; start="<main_envelope>"; boundary="=-=-=" Here’s a backtrace: --8<---------------cut here---------------start------------->8--- In debbugs/soap.scm: 101:8 9 (soap-invoke "https://debbugs.gnu.org/cgi/soap.cgi" _ . _) In web/client.scm: 386:24 8 (http-request _ #:body _ #:port _ #:method _ #:version _ #:keep-alive? _ #:headers _ #:decode-body? _ #:streaming? _ #:request _) In web/response.scm: 200:48 7 (read-response #<input-output: string 2db5690>) In web/http.scm: 225:33 6 (read-headers #<input-output: string 2db5690>) 195:11 5 (read-header #<input-output: string 2db5690>) 1606:12 4 (_ "multipart/related; type=\"text/xml\"; start=\"<main_envelope>\"; boundary=\"=-=-=\"") In ice-9/boot-9.scm: 222:29 3 (map1 (" type=\"text/xml\"" " start=\"<main_envelope>\"" " boundary=\"=-=-=\"")) 222:29 2 (map1 (" start=\"<main_envelope>\"" " boundary=\"=-=-=\"")) 222:17 1 (map1 (" boundary=\"=-=-=\"")) In web/http.scm: 1609:23 0 (_ " boundary=\"=-=-=\"") --8<---------------cut here---------------end--------------->8--- The reason why it fails is that Guile processes the response and treats the *payload* contained in the XML response as HTTP. In this case it processes the response and stumbles upon a multipart email that contains a Content-type header specifying a boundary string. The Content-type handler in (web http) doesn’t like that the boundary string contains “=” and aborts. The point is, though, that it shouldn’t even try to parse the payload of the XML response. If you want to see the full XML response you can use wget: wget --post-data="<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" soapenc:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><soap:Body><ns1:get_bug_log xmlns:ns1=\"urn:Debbugs/SOAP\" soapenc:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><ns1:bugnumber xsi:type=\"xsd:int\">32514</ns1:bugnumber></ns1:get_bug_log></soap:Body></soap:Envelope>" --header "Content-type: text/xml" -qO - "https://debbugs.gnu.org/cgi/soap.cgi" Is this a problem with Guile when a response with Content-type text/xml is received? -- Ricardo