unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andreas Schwab <schwab@suse.de>
Cc: Masatake YAMATO <jet@gyve.org>, Thien-Thi Nguyen <ttn@glug.org>,
	emacs-devel@gnu.org
Subject: Re: help with URL module needed
Date: Sun, 28 Nov 2004 20:12:57 +0100	[thread overview]
Message-ID: <jept1xzt1i.fsf@sykes.suse.de> (raw)
In-Reply-To: <200411281638.02083.pogonyshev@gmx.net> (Paul Pogonyshev's message of "Sun, 28 Nov 2004 16:38:02 +0200")

Paul Pogonyshev <pogonyshev@gmx.net> 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  <schwab@suse.de>

	* 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, schwab@suse.de
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	other threads:[~2004-11-28 19:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-26 15:32 help with URL module needed Paul Pogonyshev
2004-11-26 16:04 ` Masatake YAMATO
2004-11-26 16:58   ` Paul Pogonyshev
2004-11-28 14:38     ` Paul Pogonyshev
2004-11-28 19:12       ` Andreas Schwab [this message]
2004-11-28 22:37         ` Paul Pogonyshev
2004-11-28 22:59           ` Andreas Schwab
2004-11-28 23:12             ` Paul Pogonyshev
2004-11-28 23:43               ` Alex Schroeder
2004-11-29  0:10               ` Andreas Schwab
2004-11-29 14:01                 ` Paul Pogonyshev
2004-11-30 19:49                   ` Paul Pogonyshev
2004-11-30 21:29                     ` Andreas Schwab
2004-11-29 21:42             ` Thien-Thi Nguyen
2004-11-30  0:35               ` Andreas Schwab
2004-11-30  9:22                 ` Thien-Thi Nguyen
2004-11-30 17:18         ` Mark A. Hershberger
2004-11-26 16:27 ` Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jept1xzt1i.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=emacs-devel@gnu.org \
    --cc=jet@gyve.org \
    --cc=ttn@glug.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).