From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Translation of http status code to text Date: Tue, 23 Mar 2010 08:57:15 -0400 Message-ID: References: <87sk7vllgj.fsf@mail.jurta.org> <87hbo81onq.fsf@lifelogs.com> <87k4t4zb5l.fsf@lifelogs.com> <87r5ncxp4z.fsf@lifelogs.com> <87ljdkxj4m.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1269349409 528 80.91.229.12 (23 Mar 2010 13:03:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 23 Mar 2010 13:03:29 +0000 (UTC) Cc: emacs-devel@gnu.org To: Ted Zlatanov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 23 14:03:25 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Nu3lT-0003xq-3O for ged-emacs-devel@m.gmane.org; Tue, 23 Mar 2010 14:03:23 +0100 Original-Received: from localhost ([127.0.0.1]:49507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nu3lS-00017A-K8 for ged-emacs-devel@m.gmane.org; Tue, 23 Mar 2010 09:03:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nu3fc-0007WX-Na for emacs-devel@gnu.org; Tue, 23 Mar 2010 08:57:20 -0400 Original-Received: from [140.186.70.92] (port=33050 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nu3fb-0007Vm-BV for emacs-devel@gnu.org; Tue, 23 Mar 2010 08:57:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nu3fY-0007w8-VC for emacs-devel@gnu.org; Tue, 23 Mar 2010 08:57:19 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:25950 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nu3fY-0007vw-Sc for emacs-devel@gnu.org; Tue, 23 Mar 2010 08:57:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAANXqEvO+IPa/2dsb2JhbACbK3S7PoR9BIsZ X-IronPort-AV: E=Sophos;i="4.51,295,1267419600"; d="scan'208";a="58860597" Original-Received: from 206-248-131-218.dsl.teksavvy.com (HELO pastel.home) ([206.248.131.218]) by ironport2-out.pppoe.ca with ESMTP; 23 Mar 2010 08:57:15 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 54FD57EF9; Tue, 23 Mar 2010 08:57:15 -0400 (EDT) In-Reply-To: <87ljdkxj4m.fsf@lifelogs.com> (Ted Zlatanov's message of "Mon, 22 Mar 2010 14:15:53 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:122542 Archived-At: >>> Here's one version of the HTTP codes as an alist. I was thinking of >>> also generating defconst calls based on this list, that's why I named >>> everything "url-http-code-*". But maybe that's not necessary and >>> accessor functions will be enough, so then we can s/url-http-code-// SM> The symbol part depends on the rest of the patch: what do you use the SM> symbol for? Do you even need it? > I was going to change url-http.el like so, in url-http-parse-headers: > (case url-http-response-status > ((url-http-code-multiple-choices) ; was 300, uses defconst > ... > nil) > ...) I see, then it's OK to add symbols, I guess, but in this case use shorter ones, so you can do: (case (cadr (assq status-number url-http-codes))) (OK ...) (moved-permanently ...) (proxy-authentication-required ...) (accepted ...) ...) And in that case, a better option is to create the symbols programmatically from the error string: (defconst url-http-codes (mapcar (lambda (x) (let ((s (subst-char-in-string ?\s ?- (cadr x)))) (when (string-match "-(.*)" s) (setq s (substring s 0 (match-beginning 0)))) (list (car x) (intern (downcase s)) (cadr x)))) '((100 "Continue with request") ...))) -- Stefan