From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#30076: [PATCH] web: Recognize JSON content type as text. Date: Wed, 31 Jan 2018 01:04:32 -0500 Message-ID: <87lggeva1b.fsf@netris.org> References: <20180111053117.4597-1-arunisaac@systemreboot.net> <87y3kevh53.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1517378950 8821 195.159.176.226 (31 Jan 2018 06:09:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Jan 2018 06:09:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: 30076@debbugs.gnu.org To: Arun Isaac Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Jan 31 07:09:05 2018 Return-path: Envelope-to: guile-bugs@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 1eglZn-0001JN-Tk for guile-bugs@m.gmane.org; Wed, 31 Jan 2018 07:08:56 +0100 Original-Received: from localhost ([::1]:37850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eglbo-0003wc-V1 for guile-bugs@m.gmane.org; Wed, 31 Jan 2018 01:11:00 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eglX6-0000Pi-5N for bug-guile@gnu.org; Wed, 31 Jan 2018 01:06:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eglX1-0002vZ-0v for bug-guile@gnu.org; Wed, 31 Jan 2018 01:06:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42304) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eglX0-0002ub-SV for bug-guile@gnu.org; Wed, 31 Jan 2018 01:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eglX0-0000Z0-Df for bug-guile@gnu.org; Wed, 31 Jan 2018 01:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 31 Jan 2018 06:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30076 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch Original-Received: via spool by 30076-submit@debbugs.gnu.org id=B30076.15173787192115 (code B ref 30076); Wed, 31 Jan 2018 06:06:02 +0000 Original-Received: (at 30076) by debbugs.gnu.org; 31 Jan 2018 06:05:19 +0000 Original-Received: from localhost ([127.0.0.1]:50201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eglWH-0000Y2-8p for submit@debbugs.gnu.org; Wed, 31 Jan 2018 01:05:18 -0500 Original-Received: from world.peace.net ([50.252.239.5]:51462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eglWG-0000Xn-6N for 30076@debbugs.gnu.org; Wed, 31 Jan 2018 01:05:16 -0500 Original-Received: from pool-72-93-27-251.bstnma.east.verizon.net ([72.93.27.251] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eglWA-0002H6-1T; Wed, 31 Jan 2018 01:05:10 -0500 In-Reply-To: <87y3kevh53.fsf@netris.org> (Mark H. Weaver's message of "Tue, 30 Jan 2018 22:31:04 -0500") 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-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8993 Archived-At: Mark H Weaver writes: > RFC 4627 makes the additional interesting observation (in section 3, > "encoding") that since the first two characters of JSON text will always > be ASCII, Sorry, it turns out that's no longer the case. RFC 4627 specified that a JSON text must be either an object or array, but in RFC 7159 a JSON text can be any JSON value. So only the first character is guaranteed to be ASCII. Having looked into this a bit more, I wonder if Guile should even try to set the port encoding itself. As far as I can tell, there's no way to know the encoding of the response payload in the general case, without knowledge of the specific MIME media type. We could teach Guile about "application/json", but if we follow that path, it would lead to us teaching Guile's web library about more media types over time, but we cannot hope to know about all of them. The 'charset' parameter is not universal. Whether it is a valid parameter, and how its value is to be interpreted, depends on the media type. For "application/json", technically there is no 'charset' parameter at all. Since it's not feasible for Guile to reliably choose the right encoding for arbitrary media types, perhaps it would be better for Guile to explicitly say that it's the application programmer's job to set the encoding of the port, if it contains textual data. What do you think? Mark