From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: HTTP POST requests with url.el Date: Fri, 20 Oct 2006 19:19:07 +0200 Organization: University Koblenz-Landau Campus Koblenz Message-ID: <87ejt2ewhg.fsf@baldur.nicundtas.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1161379923 3312 80.91.229.2 (20 Oct 2006 21:32:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 20 Oct 2006 21:32:03 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 20 23:32:01 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gb1xz-0003uy-Cn for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Oct 2006 23:31:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gb1xy-0006Vz-Vm for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Oct 2006 17:31:47 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!rz.uni-karlsruhe.de!news.belwue.de!news.uni-kl.de!cache.uni-koblenz.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 104 Original-NNTP-Posting-Host: dslb-084-063-026-176.pools.arcor-ip.net Original-X-Trace: cache.uni-koblenz.de 1161364759 21282 84.63.26.176 (20 Oct 2006 17:19:19 GMT) Original-X-Complaints-To: news@cache.uni-koblenz.de Original-NNTP-Posting-Date: Fri, 20 Oct 2006 17:19:19 +0000 (UTC) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEVVVlBlsOJqkqifzOif vtFXdYWo4XLsAAAACXBIWXMAAAsSAAALEgHS3X78AAAACXZwQWcAAAAwAAAAMADO7oxXAAABp0lE QVQ4y8WTy46kMAxFLQb24zz2wJAPoJLeE+LaA6r8/6+0HYpHa9SLns1YKlTc42sTYwC/Cfg/YPzW Mf6w1KhPh/KI5iIXQOPTzeDNAWJ69PokPoQD6BZe42Hw/qM5wG/4Q15L6RG917hUj46BUlAn70fN 5bUX8IShOFoYDBN2iM6+AarIgKDykVgKTMWAZgJCUBPUaMTCMBUHTvBihwC2pZmIkg/Ej2BZgoLR QomG2hePoS9g4YI4TDup4deIvYGKAd9FJAF1uRCSgiaCWaDucJ5EErxnVTOoBZoQReLmBCwhce4s zSUXyvEDCGeFe6gPeMcbyMPBys3NDfjjv4yEm/wFyqxweBOZFB9Egsp0O5o5nXZADzn/DrCLRMGX 2Zb5ptid60OH6kMU+dorvSfL5esmyr1Brd9v5AbYJJske3IvlVKMUtAgv/tbqThHXtKuV2bjtYwX 0L3La143m6tnfl09zHOrXG7WLfet25ZwAee61rKnUW3b5PUEjy1jzi5vi1rcHVjH1fPitsxqztsJ su3VarPlX177m6OE/cfvfP2J42uTT9NRefjdwUXiAAAAJnpUWHRDb21tZW50AAB42nMuSk0sSU1R KM8syVAIyUhVcPf0DQAAUucHI5DLZXAAAAAaelRYdEpQRUctQ29sb3JzcGFjZQAAeNozAgAAMwAz ERZ+YwAAACd6VFh0SlBFRy1TYW1wbGluZy1mYWN0b3JzAAB42jOqMNIxrDAEYQARgwLpZA8bYgAA AABJRU5ErkJggg== User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:FDbVRT4PM6kT+VUkPkZ9HIKfLLg= Original-Xref: shelby.stanford.edu gnu.emacs.help:142526 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:38147 Archived-At: Hi, I'm rewriting my emms-lastfm plugin to use url.el instead of the unmaintained http-{get,post}.el. But I don't get the track submission via HTTP POST working. Here's my code: --8<---------------cut here---------------start------------->8--- (defun emms-lastfm-submit-track () "Submits the current track (`emms-lastfm-current-track') to last.fm." (interactive) (let* ((artist (emms-track-get emms-lastfm-current-track 'info-artist)) (title (emms-track-get emms-lastfm-current-track 'info-title)) (album (emms-track-get emms-lastfm-current-track 'info-album)) (musicbrainz-id "") (track-length (number-to-string (emms-track-get emms-lastfm-current-track 'info-playing-time))) (date (format-time-string "%Y-%m-%d %H:%M:%S" (current-time) t)) (url-http-attempt-keepalives nil) (url-request-method "POST") (url-request-data (concat "u=" emms-lastfm-username "&s=" (md5 (concat (md5 emms-lastfm-password) emms-lastfm-md5-challenge)) "&a[0]=" artist "&t[0]=" title "&b[0]=" album "&m[0]=" musicbrainz-id "&l[0]=" track-length "&i[0]=" date "\r\n"))) (setq emms-lastfm-buffer (url-retrieve emms-lastfm-submit-url 'emms-lastfm-submission-sentinel)))) (defun emms-lastfm-submission-sentinel () "Is called after a track submission to last.fm was made." (save-excursion (set-buffer emms-lastfm-buffer) (if (re-search-forward "OK" nil t 2) (message "\"%s\" submitted..." (emms-track-description emms-lastfm-current-track)) ;; TODO: Inform the user what went wrong. (message "Song couldn't be submitted")))) --8<---------------cut here---------------end--------------->8--- When the request is done I get this in *URL-DEBUG*: ,---- | http -> Contacting host: 62.216.251.205:80 | http -> Marking connection as busy: 62.216.251.205:80 # | http -> Request is: | POST /protocol_1.1 HTTP/1.1 | MIME-Version: 1.0 | Connection: close | Extension: Security/Digest Security/SSL | Host: 62.216.251.205 | Accept-charset: utf-8;q=1, iso-8859-1;q=0.5, iso-8859-15;q=0.5, windows-1252;q=0.5, big5;q=0.5, iso-2022-jp;q=0.5, shift_jis;q=0.5, iso-8859-2;q=0.5, iso-8859-3;q=0.5, iso-8859-4;q=0.5, iso-8859-5;q=0.5, iso-8859-7;q=0.5, iso-8859-8;q=0.5, iso-8859-9;q=0.5, gb2312;q=0.5, euc-jp;q=0.5, euc-kr;q=0.5, tis-620;q=0.5, iso-8859-14;q=0.5, windows-1251;q=0.5, koi8-r;q=0.5, koi8-u;q=0.5, viscii;q=0.5, hz-gb-2312;q=0.5, iso-2022-cn-ext;q=0.5, iso-2022-cn;q=0.5, iso-2022-jp-2;q=0.5, iso-2022-kr;q=0.5, utf-16;q=0.5, utf-16be;q=0.5, utf-16le;q=0.5 | Accept: */* | User-Agent: URL/Emacs (i686-pc-linux-gnu; X11) | Content-length: 172 | | u=heimdall80&s=7728cf8409b2888f4a5077c26480798f&a[0]=Leonard Cohen&t[0]=Waiting For The Miracle (Edited)&b[0]=Natural Born Killers&m[0]=&l[0]=223&i[0]=2006-10-20 17:09:14 | | http -> Calling after change function `url-http-wait-for-headers-change-function' for `#' | http -> url-http-wait-for-headers-change-function ( *http 62.216.251.205:80*) | http -> Saw end of headers... ( *http 62.216.251.205:80*) | http -> url-http-parse-response called in ( *http 62.216.251.205:80*) | http -> No content-length, being dumb. | http -> url-http-end-of-document-sentinel in buffer ( *http 62.216.251.205:80*) | http -> Marking connection as free: 62.216.251.205:80 # | http -> url-http-parse-headers called in ( *http 62.216.251.205:80*) | http -> url-http-parse-response called in ( *http 62.216.251.205:80*) | http -> Parsed HTTP headers: class=2 status=200 | http -> Finished parsing HTTP headers: t | http -> Marking connection as free: 62.216.251.205:80 # | http -> Activating callback in buffer ( *http 62.216.251.205:80*) `---- But the server response tells me there was something wrong with my post data. ,---- | HTTP/1.1 200 OK | Server: Apache-Coyote/1.1 | Pragma: no-cache | Cache-Control: no-cache | Content-Type: text/plain;charset=ISO-8859-1 | Date: Fri, 20 Oct 2006 17:09:14 GMT | Connection: close | | FAILED Plugin bug: Not all request variables are set - no POST | parameters. INTERVAL 1 `---- Does anyone know what I'm doing wrong, or how I can find the bug? Bye and thanks, Tassilo -- [Emacs] is written in Lisp, which is the only computer language that is beautiful. -- Neal Stephenson, _In the Beginning was the Command Line_