From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Schreiber Newsgroups: gmane.emacs.bugs Subject: bug#24365: 24.4; [PATCH] url-http-options fails when connection refused Date: Sun, 04 Sep 2016 01:15:24 -0700 Message-ID: <87inucqdwj.fsf@war.peplook.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1473006688 9919 195.159.176.226 (4 Sep 2016 16:31:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Sep 2016 16:31:28 +0000 (UTC) To: 24365@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 04 18:31:24 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgaKD-0001MO-Nx for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Sep 2016 18:31:17 +0200 Original-Received: from localhost ([::1]:50521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgaKB-0003uZ-8j for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Sep 2016 12:31:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgaK3-0003tr-JR for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 12:31:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgaJz-0001LV-AG for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 12:31:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgaJz-0001LR-7Q for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 12:31:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bgaJz-0006Pa-3F for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 12:31:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark Schreiber Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Sep 2016 16:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24365 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.147300663424595 (code B ref -1); Sun, 04 Sep 2016 16:31:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Sep 2016 16:30:34 +0000 Original-Received: from localhost ([127.0.0.1]:49868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgaJW-0006Oc-EL for submit@debbugs.gnu.org; Sun, 04 Sep 2016 12:30:34 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34557) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgSal-0000aJ-2b for submit@debbugs.gnu.org; Sun, 04 Sep 2016 04:15:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgSae-0001Xl-On for submit@debbugs.gnu.org; Sun, 04 Sep 2016 04:15:45 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:39913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgSae-0001Xh-LS for submit@debbugs.gnu.org; Sun, 04 Sep 2016 04:15:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgSac-000588-Ce for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 04:15:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgSaW-0001X5-CN for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 04:15:41 -0400 Original-Received: from d.mail.sonic.net ([64.142.111.50]:41554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgSaW-0001Wy-33 for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 04:15:36 -0400 Original-Received: from war.peplook.com (173-228-89-34.dsl.static.fusionbroadband.com [173.228.89.34]) (authenticated bits=0) by d.mail.sonic.net (8.15.1/8.15.1) with ESMTPSA id u848FP7Q002547 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sun, 4 Sep 2016 01:15:25 -0700 Original-Received: from mark7 by war.peplook.com with local (Exim 4.84_2) (envelope-from ) id 1bgSaK-0006gG-Vr for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2016 01:15:24 -0700 X-Sonic-CAuth: UmFuZG9tSVbyWFscbjjAYtOI94c437v1tCOZktCAghc+YkRIGotM5HhB88f/QW+Lr9FxihjIvPcCgv3ps1npO985lSnCcP17 X-Sonic-ID: C;XIpZu3dy5hG+n6/hcgQksw== M;Wj6su3dy5hG+n6/hcgQksw== X-Sonic-Spam-Details: 0.0/5.0 by cerberusd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Sun, 04 Sep 2016 12:30:32 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:122938 Archived-At: url-http-options fails when a web server refuses its connection. Evaluating (url-http-options "http://127.0.0.1:33333/") results in the following error: Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) url-http-options("http://127.0.0.1:33333/") eval((url-http-options "http://127.0.0.1:33333/") nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp) In my case, this caused the third-party package org-caldav to fail with this error when M-x org-caldav-sync was invoked and given an incorrect org-caldav-url. I believe that the correct behavior would be to have url-http-options return nil, which is the behavior of that function when it receives an HTTP error response. The issue is still present in master. The following patch against master causes url-http-options to return nil in the above case. --- url-http-options would fail internally when passed an URL to a web server refusing the connection. Change its behavior to return nil, as would occur if an HTTP error code were received. * lisp/url/url-http.el (url-http-options) Copyright-paperwork-exempt: yes --- lisp/url/url-http.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 927d0bb..e55b645 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -1512,10 +1512,11 @@ url-http-options (let* ((url-request-method "OPTIONS") (url-request-data nil) (buffer (url-retrieve-synchronously url)) + (response-status (when buffer (url-http-symbol-value-in-buffer + 'url-http-response-status buffer 0))) (header nil) (options nil)) - (when (and buffer (= 2 (/ (url-http-symbol-value-in-buffer - 'url-http-response-status buffer 0) 100))) + (when (and response-status (= 2 (/ response-status 100))) ;; Only parse the options if we got a 2xx response code! (with-current-buffer buffer (save-restriction -- 2.1.4