emacs-devel
[Top][All Lists]
Advanced

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

Re: help with URL module needed


From: Andreas Schwab
Subject: Re: help with URL module needed
Date: Sun, 28 Nov 2004 20:12:57 +0100
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Paul Pogonyshev <address@hidden> writes:

> So, I'll ease it.  Evaluate these two functions and type
> `M-x wikipedia-login RET':
>
> (defun wikipedia-login ()
>   (interactive)
>   (let ((domain                    "en")
>       (url-request-method        "POST")
>       (url-request-extra-headers '(("Content-Type" . 
> "application/x-www-form-urlencoded")))
>       (url-request-data
>        (wikipedia-build-post-data '(("wpName"         . "Testy Test")
>                                     ("wpLoginattempt" . "Login")
>                                     ("wpPassword"     . "test")
>                                     ("wpRetype"       . "")
>                                     ("wpEmail"        . ""))))
>       (url-debug           t))
>     (url-retrieve (concat "http://"; domain 
> ".wikipedia.org/w/wiki.phtml?title=Special:Userlogin&action=submit")
>                 (lambda () (pop-to-buffer (current-buffer))))))
>
> (defun wikipedia-build-post-data (post-data-alist)
>   (mapconcat (lambda (association)
>              (concat (car association) "="
>                      (url-hexify-string (cdr association))))
>            post-data-alist "&"))
>
> You should get a ``411 Length Required''.

The problem is that url-http-create-request does not account for the
trailing CRLF in the Content-Length, or rather that it sends the trailing
CRLF in the first place.

I've checked in this patch to fix it:

2004-11-28  Andreas Schwab  <address@hidden>

        * url-http.el (url-http-create-request): Don't add newline after
        the request data.

--- lisp/url/url-http.el        19 Apr 2004 09:48:36 +0200      1.5
+++ lisp/url/url-http.el        28 Nov 2004 20:06:35 +0100      
@@ -255,15 +255,16 @@ request.
           (if ref-url (concat
                        "Referer: " ref-url "\r\n"))
           extra-headers
-          ;; Any data
+          ;; Length of data
           (if url-request-data
               (concat
                "Content-length: " (number-to-string
                                    (length url-request-data))
-               "\r\n\r\n"
-               url-request-data))
+               "\r\n"))
           ;; End request
-          "\r\n"))
+          "\r\n"
+          ;; Any data
+          url-request-data))
     (url-http-debug "Request is: \n%s" request)
     request))
 

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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