Subject: bug#11469: 24.1.50; url-retrieve with PUT method fails every two times

From: Takafumi Arakaki <[email-masked]>
Date: Mon, 14 May 2012 13:31:05 +0200

This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org.  Please check that
the From: line contains a valid email address.  After a delay of up
to one day, you should receive an acknowledgement at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.

Please describe exactly what actions triggered the bug, and
the precise symptoms of the bug.  If you can, give a recipe
starting from `emacs -Q':

I found some probelem using url-retrieve.  To reproduce the probelem you
can use the following snippet:

(let ((url "http://127.0.0.1:9999/")
      (url-request-method "PUT")
      (url-request-extra-headers '(("Content-Type" . "application/json")))
      (url-request-data "[1 2 3]"))
  (url-retrieve url (lambda (status))))

I am executing the above snippet (using eval-last-sexp at the end of the
exnippet) and it fails every two times (it succeeds and then fails and
then succeeds and then ...).  I got this message when it fails:

error in process sentinel: url-http-end-of-document-sentinel: Symbol's
value as variable is void: url-request-method
error in process sentinel: Symbol's value as variable is void:
url-request-method

I checked above with emacs started by emacs-snapshot -Q.

Furthremore, in some case I have url-request-method set to nil at global
lavel (M-: url-request-method RET gives nil).  And in this case, GET
method is used instead.  I guess this is because of
"(or url-request-method "GET")" in url-http.

I guess it won't matter, but I am using Python tornado as a web server
to check the behavior.  This is the test server I am using:

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):

    def get(self):
        print "GET"
        print self.request.body
        self.write("Hello, world")
        self.finish()

    def put(self):
        print "PUT"
        print self.request.body
        self.set_status(204)
        self.finish()

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(9999)
    tornado.ioloop.IOLoop.instance().start()

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/share/emacs/24.1.50/etc/DEBUG.

In GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.22.0)
 of 2012-04-10 on mercury, modified by Debian
 (emacs-snapshot package, version 2:20120410-1~ppa1~maverick1)
Windowing system distributor `The X.Org Foundation', version 11.0.10900000
Configured using:
 `configure '--build' 'i686-linux-gnu' '--host' 'i686-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp'
 '--without-compress-info' '--with-crt-dir=/usr/lib//' '--with-x=yes'
 '--with-x-toolkit=gtk' '--with-imagemagick=yes'
 'build_alias=i686-linux-gnu' 'host_alias=i686-linux-gnu'
 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g
 -Wl,--as-needed -znocombreloc' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-x C-f C-y <return> C-x C-f <up> <backspace> <backspace>
p <tab> <return> C-x b <return> C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-e C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-e C-x C-e C-x C-e C-x C-e C-e C-f C-p C-p
C-p C-p C-p C-p C-p C-p C-p M-m C-p C-f C-p C-s C-w
C-w C-w C-s C-s C-n C-a C-n C-n C-n C-n C-n C-n C-n
C-n C-e C-n C-e C-x C-e C-x C-e C-n C-p C-n C-n C-e
C-p C-e C-p C-p C-e C-p C-p C-p C-p C-e C-p C-e C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-e C-p C-e M-x e <backspace>
b u g - r e <tab> <tab> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> e m a <tab> b <tab> C-g M-x r e p o <tab>
r <tab> <tab> <return>

Recent messages:
(buffer-string) =
HTTP/1.1 204 No Content
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Server: TornadoServer/2.2
 [2 times]
byte-code: End of buffer [2 times]
Making completion list...
Quit
Making completion list... [2 times]

Load-path shadows:
/usr/share/emacs/24.1.50/site-lisp/debian-startup hides
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs/24.1.50/site-lisp/cmake-data/cmake-mode hides
/usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/site-lisp/rst hides /usr/share/emacs/24.1.50/lisp/textmodes/rst

Features:
(shadow sort mail-extr emacsbug message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader sendmail
help-mode view multi-isearch mail-utils network-stream starttls url-http
tls mail-parse rfc2231 rfc2047 rfc2045 ietf-drums url-gw url-cache
url-auth url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util url-parse auth-source eieio byte-opt
bytecomp byte-compile cconv macroexp assoc gnus-util password-cache
url-vars mm-util mail-prsvr mailcap python-21 python easymenu comint
regexp-opt ansi-color ring time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)