unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Arun Isaac <arunisaac@systemreboot.net>
Cc: 30076@debbugs.gnu.org
Subject: bug#30076: [PATCH] web: Recognize JSON content type as text.
Date: Wed, 31 Jan 2018 01:04:32 -0500	[thread overview]
Message-ID: <87lggeva1b.fsf@netris.org> (raw)
In-Reply-To: <87y3kevh53.fsf@netris.org> (Mark H. Weaver's message of "Tue, 30 Jan 2018 22:31:04 -0500")

Mark H Weaver <mhw@netris.org> 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





  reply	other threads:[~2018-01-31  6:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11  5:31 bug#30076: [PATCH] web: Recognize JSON content type as text Arun Isaac
2018-01-31  3:31 ` Mark H Weaver
2018-01-31  6:04   ` Mark H Weaver [this message]
2018-02-02  7:31     ` Arun Isaac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lggeva1b.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=30076@debbugs.gnu.org \
    --cc=arunisaac@systemreboot.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).