From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: help with URL module needed Date: Sun, 28 Nov 2004 20:12:57 +0100 Message-ID: References: <200411261732.12616.pogonyshev@gmx.net> <20041127.010441.112625752.jet@gyve.org> <200411261858.20645.pogonyshev@gmx.net> <200411281638.02083.pogonyshev@gmx.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1101669220 3570 80.91.229.6 (28 Nov 2004 19:13:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 28 Nov 2004 19:13:40 +0000 (UTC) Cc: Masatake YAMATO , Thien-Thi Nguyen , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 28 20:13:32 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CYUUF-0001WT-00 for ; Sun, 28 Nov 2004 20:13:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYUdc-0004CB-9t for ged-emacs-devel@m.gmane.org; Sun, 28 Nov 2004 14:23:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CYUdV-0004Bs-JN for emacs-devel@gnu.org; Sun, 28 Nov 2004 14:23:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CYUdU-0004BY-TV for emacs-devel@gnu.org; Sun, 28 Nov 2004 14:23:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYUdU-0004BO-NU for emacs-devel@gnu.org; Sun, 28 Nov 2004 14:23:04 -0500 Original-Received: from [195.135.220.2] (helo=Cantor.suse.de) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CYUTo-00038f-B3 for emacs-devel@gnu.org; Sun, 28 Nov 2004 14:13:04 -0500 Original-Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 06F0F11843C2; Sun, 28 Nov 2004 20:13:00 +0100 (CET) Original-To: Paul Pogonyshev X-Yow: I want a VEGETARIAN BURRITO to go.. with EXTRA MSG!! In-Reply-To: <200411281638.02083.pogonyshev@gmx.net> (Paul Pogonyshev's message of "Sun, 28 Nov 2004 16:38:02 +0200") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:30460 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30460 Paul Pogonyshev 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=3DSpecial:Userlogin&action=3Dsubmit") > (lambda () (pop-to-buffer (current-buffer)))))) > > (defun wikipedia-build-post-data (post-data-alist) > (mapconcat (lambda (association) > (concat (car association) "=3D" > (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 * 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=09 @@ -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)) =20 Andreas. --=20 Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra=DFe 5, 90409 N=FCrnberg, Germany Key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."