bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30076: [PATCH] web: Recognize JSON content type as text.


From: Mark H Weaver
Subject: bug#30076: [PATCH] web: Recognize JSON content type as text.
Date: Wed, 31 Jan 2018 01:04:32 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Mark H Weaver <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]