Subject: bug#10478: 24.0.50; url-http-parse-headers can silently drop the response when handling BASIC AUTHENTICATION

From: Jerry Asher <[email-masked]>
Date: Wed, 11 Jan 2012 00:03:06 -0700

From: Jerry Asher <[email-masked]>
To: [email-masked]
Subject: 24.0.50; url-http-parse-headers can silently drop the
response when handling BASIC AUTHENTICATION
Date: Tue, 10 Jan 2012 23:59:59 -0700
Message-ID: <[email-masked]>
--text follows this line--
I am developing an interface to posterous.com.  Posterous has a restful
api described at posterous.com/api.

They require basic authentication.

When making a GET request again their simplest api, users/me that
returns information about the logged in user, url-retrieve-synchronously
will return the wrong buffer.

This seems to be traceable to url-http-parse-headers handling the "401
Basic: Access denied message by" calling url-http-handle-authentication
which prompts the user for a name and password and calls
url-retrieve-internal to retry the request.

This time, url-retrieve-internal will add in the authentication header,
and so the request will succeed in a 200.  At that point
url-retrieve-will return the buffer the response is in,
url-http-handle-authentication will return that buffer, but
url-http-parse-header will drop that new buffer on the floor, silently.

In a similar case, url-http-parse-header will for a 30X redirect uris,
set a buffer local variable url-redirect-buffer.

It would seem that something similar to this needs to be done for 401
Unauthorized basic authentication.

In GNU Emacs 24.0.50.1 (i386-mingw-nt6.1.7601)
 of 2011-09-19 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 6.1.7601
configured using `configure --with-gcc (4.5) --no-opt'

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: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  eldoc-mode: t
  display-time-mode: t
  desktop-save-mode: t
  projectile-global-mode: t
  yas/global-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  savehist-mode: t
  electric-layout-mode: t
  electric-indent-mode: t
  global-auto-revert-mode: t
  delete-selection-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: 1

Recent input:
C-s C-s C-s C-l C-a C-n C-n C-n C-n C-n C-n C-f C-a
C-s C-a C-s u r l - h t t p - h a n d l e - a u C-s
C-s C-r C-r C-r C-a C-a C-s u r l - b a s i c - a C-s
C-a C-x 2 C-x o <escape> x f i n d - g r e p <return>
u r l - b u g - a d C-a C-f C-f C-f C-f C-f C-f C-f
- n a m e SPC * <backspace> " * e l " SPC C-e <return>
C-x p C-x p q C-x p C-x 0 C-x o C-a C-s u r l - t <backspace>
r e t r i C-a <escape> C-f C-e <escape> C-b C-s u r
l - h t t p - h a n d l e - a u t h e t <backspace>
n t i c a t i o n C-a C-x o C-x b * U R <tab> <return>
C-s h a n d l i n e <backspace> g C-s C-a C-x o C-x
2 C-x o <escape> x <up> <return> <up> C-e C-b C-b C-b
C-b C-b C-b <escape> <backspace> <escape> <backspace>
h t t p - h a n d l e <return> <escape> < C-s h r l
- <backspace> <backspace> <backspace> <backspace> u
r l - h a n d l <backspace> <backspace> <backspace>
<backspace> t t p - h a n d l e - a C-s C-s C-r C-r
C-a C-l C-x 1 C-e C-b <down-mouse-1> <mouse-1> C-x
3 <escape> x r p o <backspace> <backspace> e p o r
t - b u g <escape> b e m a c s - <return>

Recent messages:
Mark saved where search started
Mark set
Mark saved where search started
Mark set
Mark saved where search started [3 times]
Grep finished (matches found)
Mark saved where search started [3 times]
Grep finished (matches found)
Mark set
Mark saved where search started

Load-path shadows:
c:/users/jerry/d/Dropbox/emacs/site/site-start hides c:/Program Files
(x86)/emacs/emacs-24.0.50/../site-lisp/site-start
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/ezimage hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/ezimage
c:/users/jerry/d/Dropbox/emacs-prelude/personal/custom hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/custom
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/pulse hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/cedet/pulse
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/mode-local hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/cedet/mode-local
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/inversion hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/cedet/inversion
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/data-debug hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/cedet/data-debug
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/cedet hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/cedet/cedet
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/cedet-idutils
hides c:/Program Files
(x86)/emacs/emacs-24.0.50/lisp/cedet/cedet-idutils
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/cedet-global
hides c:/Program Files
(x86)/emacs/emacs-24.0.50/lisp/cedet/cedet-global
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/cedet-files hides
c:/Program Files (x86)/emacs/emacs-24.0.50/lisp/cedet/cedet-files
c:/users/jerry/d/Dropbox/emacs/site/cedet-1.0/common/cedet-cscope
hides c:/Program Files
(x86)/emacs/emacs-24.0.50/lisp/cedet/cedet-cscope

Features:
(shadow mail-extr message rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mailabbrev gmm-utils mailheader emacsbug grep dired-aux
url-cache apropos cus-edit cus-start cus-load mail-utils network-stream
starttls debug posterous url-http tls url-auth mail-parse rfc2231
rfc2047 rfc2045 ietf-drums url-gw url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-util url-parse url-vars mailcap
paredit find-func multi-isearch mule-util help-mode view time-stamp
vc-git eldoc dired time desktop prelude-xml prelude-scheme prelude-ruby
feature-mode cucumber-mode scss-mode flymake compile derived haml-mode
js json newcomment cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs markdown-mode noutline outline
css-mode ruby-end ruby-block easy-mmode ruby-mode yari ansi-color
prelude-markdown prelude-emacs-lisp prelude-common-lisp prelude-lisp
prelude-c prelude-global-keybindings prelude-editor projectile yasnippet
edmacro kmacro tramp tramp-compat auth-source eieio assoc gnus-util
mm-util mail-prsvr password-cache shell pcomplete format-spec
tramp-loaddefs windmove recentf tree-widget wid-edit savehist saveplace
uniquify electric autorevert delsel prelude-core byte-opt warnings
bytecomp byte-compile cconv macroexp imenu thingatpt prelude-packages
anything-autoloads auctex-autoloads tex-site info easymenu
clojure-mode-autoloads coffee-mode-autoloads deft-autoloads
gist-autoloads haskell-mode-autoloads icomplete+-autoloads
lacarte-autoloads magit-autoloads markdown-mode-autoloads
paredit-autoloads projectile-autoloads sass-mode-autoloads
haml-mode-autoloads scss-mode-autoloads slime-autoloads
synonyms-autoloads wgrep-autoloads yaml-mode-autoloads yari-autoloads
yasnippet-autoloads package tabulated-list prelude-ui url-coding paren
sort cygwin-mount ange-ftp comint regexp-opt ring executable cl server
advice help-fns advice-preload time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 disp-table ls-lisp w32-win w32-vars
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 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
multi-tty emacs)