From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: coroa@online.de (Jonas Hoersch) Newsgroups: gmane.emacs.bugs Subject: bug#13598: 24.3.50; url-http.el doesn't correctly parse headers when they are sent line-by-line Date: Thu, 31 Jan 2013 18:26:54 +0100 Message-ID: <87d2wluuu9.fsf@online.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1359655835 15586 80.91.229.3 (31 Jan 2013 18:10:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Jan 2013 18:10:35 +0000 (UTC) To: 13598@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 31 19:10:54 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U0yb0-0005Es-A9 for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Jan 2013 19:10:46 +0100 Original-Received: from localhost ([::1]:38965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0yai-00029M-3n for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Jan 2013 13:10:28 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0yac-0001xY-Ef for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2013 13:10:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U0yaZ-0003c2-8R for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2013 13:10:22 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0yaZ-0003bv-5W for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2013 13:10:19 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1U0ybG-0004z4-4l for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2013 13:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: coroa@online.de (Jonas Hoersch) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Jan 2013 18:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.135965582819108 (code B ref -1); Thu, 31 Jan 2013 18:11:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Jan 2013 18:10:28 +0000 Original-Received: from localhost ([127.0.0.1]:57902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U0yah-0004y8-44 for submit@debbugs.gnu.org; Thu, 31 Jan 2013 13:10:27 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:52394) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U0xvZ-0003ww-OF for submit@debbugs.gnu.org; Thu, 31 Jan 2013 12:27:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U0xuo-0007Wp-3H for submit@debbugs.gnu.org; Thu, 31 Jan 2013 12:27:14 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:57687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0xuo-0007Wk-0n for submit@debbugs.gnu.org; Thu, 31 Jan 2013 12:27:10 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0xui-0002yA-EN for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2013 12:27:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U0xud-0007US-Ff for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2013 12:27:04 -0500 Original-Received: from mail-bk0-f49.google.com ([209.85.214.49]:42384) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0xud-0007U3-9l for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2013 12:26:59 -0500 Original-Received: by mail-bk0-f49.google.com with SMTP id w11so1465955bku.8 for ; Thu, 31 Jan 2013 09:26:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:subject:date:message-id:user-agent :mime-version:content-type:content-transfer-encoding; bh=VcU/0EK8T9yhdIMy+bcaMJar6zv1RklAZODPvP/J954=; b=YYa+iJ7PjwYaJFdXCC1COZnmjjX8jZqklpFugmCtQMRMMClRvTRsxKwoYx3KCJwMOS 1GGfv/rsVX4zoNnZdRxZs7cOnKfak+oDtxFjzelCQGJPti7IpBkPUjq7NefG5kbTr3bh u6HVvMuj96L+fsSxRT2wVG+RtuOAH1CzRYWNX0iYyYeoCGAN1uDhR21aGQwwyEkU3zUj wTmPgbo7CG8JaV6Iq1oap5HdpCNpdDRdg5jXU9QwRkjHWr+RGL0M7h2h19cSkgKuLL/Q +5t+vKFrciUPkkcpzYKtnKGH5ObGAu43N9ejCYGOMOCz9nLl1Gj8ss90ZysTC6Td4/V4 Dfow== X-Received: by 10.204.127.6 with SMTP id e6mr2439845bks.13.1359653217792; Thu, 31 Jan 2013 09:26:57 -0800 (PST) Original-Received: from kafka (dslb-178-000-019-197.pools.arcor-ip.net. [178.0.19.197]) by mx.google.com with ESMTPS id b21sm913222bkw.12.2013.01.31.09.26.56 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 31 Jan 2013 09:26:56 -0800 (PST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Thu, 31 Jan 2013 13:10:25 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70533 Archived-At: hej, everyone, i just finished hunting down an improbable bug in url-http.el, which appears when a url is retrieved from a server which sends the headers line-by-line instead of in one junk, like it is the case for the BaseHTTPServer classes coming along in python 2. A simple test-case looks like the following (sorry for the long non-emacs setup stuff, but it's the minimalist example i could come up with) cd into a directory containing only a single minimal text file and start python's SimpleHTTPServer so it serves it. $ cd $(mktemp -d) $ echo "hello world" > textfile $ python -m SimpleHTTPServer 8000 # works only for python 2.x (switch-to-buffer (url-retrieve-synchronously "http://127.0.0.1:8000/textfile")) now correctly will retrieve the "hello world" but the buffer-local-variables url-http-content-type and url-http-content-length are nil in the returned buffer, although one sees that they have been transmitted by python. adding an extra debug line to url-http's url-http-wait-for-headers-change-function around line 1043, ------ (when (re-search-forward "^\r*$" nil t) ;; Saw the end of the headers (url-http-debug "Saw end of headers... (%s)" (buffer-name))=20=20=20=20= =20=20=20=20=20=20 + (url-http-debug "when the buffer contained...\n%s" (buffer-substr= ing (point-min) (point-max))) (setq url-http-end-of-headers (set-marker (make-marker) (point)) end-of-headers t) ------- will show you in *URL-DEBUG* (url-debug being t) ------- http -> Saw end of headers... ( *http 127.0.0.1:8000*-273882) http -> when the buffer contained... HTTP/1.0 200 OK Server: SimpleHTTP/0.6 Python/2.7.3 http -> url-http-parse-response called in ( *http 127.0.0.1:8000*-273882) http -> No content-length, being dumb. ------- that the headers haven't completely arrived yet, when url-http decides it has seen the end of them. changing the regex in (re-search-forward "^\r*$" nil t) to "^\r*\n" solves the problem for me, but i'm unsure about what i might possibly be breaking that way. thanks for looking into it, jonas h=C3=B6rsch In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll b= ars) of 2013-01-29 on kafka Bzr revision: michael.albinus@gmx.de-20130129081211-mmthn9p4bh75h5pr Windowing system distributor `The X.Org Foundation', version 11.0.11302000 Configured using: `configure --prefix=3D/usr --sysconfdir=3D/etc --localstatedir=3D/var --libexecdir=3D/usr/lib --mandir=3D/usr/share/man --without-sound --with-xft --with-x-toolkit=3Dlucid' Important settings: value of $LANG: en_GB.UTF-8 locale-coding-system: utf-8-unix default enable-multibyte-characters: t