emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: encoding and content-length for url-http.el


From: Mark A. Hershberger
Subject: Re: encoding and content-length for url-http.el
Date: Thu, 16 Jun 2005 00:21:44 -0400

On Fri, 2005-06-10 at 17:22 -0400, Stefan Monnier wrote:
> Could you describe much more precisely what you're doing (especially
> how
> you use the URL package: which functions of it you call, etc...).
> Are you using WebDAV (i.e. url-dav.el)?

I'm not using url-dav.el -- I'm using xml-rpc.el which I maintain.

However, to eliminate the reliance on external code, I've pulled the bit
from xml-rpc.el that makes the call to post to a weblog hosted on
Blogger.com:

        (let ((url-debug t)) (setq url-request-data "<?xml version=\"1.0\" 
encoding=\"UTF-8\"?><methodCall><methodName>blogger.newPost</methodName><params><param><value><string>0123456789ABCDEF</string></value></param><param><value><string>9380140</string></value></param><param><value><string>usrname</string></value></param><param><value><string>passwrd</string></value></param><param><value><string>Iñtërnâtiônàlizætiøn
 from emacs with 
patch</string></value></param><param><value><boolean>1</boolean></value></param></params></methodCall>")
        
          (setq my-resp (unwind-protect
              (save-excursion
                (let ((url-working-buffer (get-buffer-create
                                           (xml-rpc-get-temp-buffer-name)))
                      (url-request-method "POST")
                      (url-request-coding-system 'utf-8)
                      (url-http-attempt-keepalives nil)
                      (url-request-extra-headers (list 
                                                  (cons "Content-Type" 
"text/xml; charset=utf-8"))))
                  (set-buffer url-working-buffer)
                  (let ((buffer (url-retrieve-synchronously 
"http://plant.blogger.com/api/RPC2";))
                        result)
                    (set-buffer buffer)
                    (url-http-parse-headers)
                    (if (> url-http-response-status 299)
                        (error "Error during request: %s"
                               url-http-response-status))
                    (url-extract-mime-headers)
                    (setq result (xml-rpc-request-process-buffer buffer))
                    result))))))

Without the patch that I supplied, this results in a server error:
"unexpected end of file found"

With the patch, it works perfectly.  The result can be seen at
http://emacs-weblogger.blogspot.com/

(I originally used the LiveJournal platform, but decided it wasn't good
enough for this demonstration since it uses Perl's SOAP::Lite which is
very liberal in what it accepts.  Blogger.com runs on Java and Java's
static typing makes it stricter in what it will accept when it comes to
XML-RPC types.)

For purposes of this report, I've attached a .zip file with my a elisp
snippets, a perl snippet and some packet traces of the working and
non-working code.  I've elided my username and password, but you'll be
able to see that the server fails when I submit without the patch and
succeeds when I submit with the patch.

Further, the only differences in the packet traces are the way
"Iñtërnâtiônàlizætiøn" is encoded and the Content-Length header.

I'm fully prepared to admit that my patch only works in this case
because of some fluke, but the fact is that url-http.el works with the
patch and fails without it.  I humbly ask your assistance in fixing
url-http.el.

-- 
http://mah.everybody.org/weblog/
GPG Fingerprint: 7E15 362D A32C DFAB E4D2  B37A 735E F10A 2DFC BFF5
More people are killed every year by pigs than by sharks, which shows
you how good we are at evaluating risk. -- Bruce Schneier

Attachment: emacs-xml-url.zip
Description: Zip archive

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]