unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: David Edmondson <dme@dme.org>, Pieter Praet <pieter@praet.org>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH] Output unmodified Content-Type header value for JSON format.
Date: Sun, 15 Jan 2012 12:58:40 -0500	[thread overview]
Message-ID: <87boq4q23z.fsf@awakening.csail.mit.edu> (raw)
In-Reply-To: <cun1ur16v3r.fsf@hotblack-desiato.hh.sledj.net>

On Sun, 15 Jan 2012 11:52:40 +0000, David Edmondson <dme@dme.org> wrote:
> > Technically the IRC discussion was about not including *any* part
> > content in the JSON output, and always using show --format=raw or
> > similar to retrieve desired parts.  Currently, notmuch includes part
> > content in the JSON only for text/*, *except* when it's text/html.  I
> > assume non-text parts are omitted because binary data is hard to
> > represent in JSON and text/html is omitted because some people don't
> > need it.  However, this leads to some peculiar asymmetry in the Emacs
> > code where sometimes it pulls part content out of the JSON and
> > sometimes it retrieves it using show --format=raw.  This in turn leads
> > to asymmetry in content encoding handling, since notmuch handles
> > content encoding for parts included in the JSON (and there's no good
> > way around that since JSON is Unicode), but not for parts retrieved as
> > raw.
> 
> Including the text output in the JSON results in significantly fewer
> calls to 'notmuch' during the building of a typical `notmuch-show-mode'
> buffer. Someone with one of those older, crankier computers could easily
> test how much effect this has by changing
> `notmuch-show-get-bodypart-content' slightly.

Yes.  I was mostly reiterating the IRC discussion for Pieter.  Since
this discussion, I've stabilized on the pre-fetching notion I described
in id:"20120115003617.GH1801@mit.edu", though I do think we should make
this clear in the code: that the rule for whether the JSON includes a
"content" key for a leaf part is internal to the CLI and that consumers
should be prepared to use it if it's there and to retrieve the content
separately if it's not.  This is exactly how the Emacs code happens to
work, it just hasn't been codified anywhere.  Looking at it this way
gives us more flexibility than the current code takes advantage of; for
example we could omit content from the JSON if it's over some size
threshold since the cost of sending that to a client that doesn't need
it is high while the cost of having the client retrieve it for itself is
relatively low.

> > The idea discussed on IRC was to remove all part content from the JSON
> > output and to always use show to retrieve it, possibly beefing up
> > show's support for content decoding (and possibly introducing a way to
> > retrieve multiple raw parts at once to avoid re-parsing).  This would
> > get the JSON format out of the business of guessing what consumers
> > need, simplify the Emacs code, and normalize content encoding
> > handling.
> 
> Is there a real problem being solved here? Having a clean structure is
> nice, except when it's not.

The "real" problem is the asymmetry in encoding handling that started
this discussion.  Content included in the JSON is re-encoded by the CLI,
while content retrieved via raw needs to be re-encoded by the client.

OTOH, I don't understand the encoding story for HTML, since the encoding
can come from either a header or from the body of the HTML.  Does this
make it strictly necessary for the client to handle the encoding?

  reply	other threads:[~2012-01-15 17:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18 23:45 [PATCH] Output unmodified Content-Type header value for JSON format Dmitry Kurochkin
2011-11-19  1:58 ` Jameson Graef Rollins
2011-11-19  2:42   ` Dmitry Kurochkin
2011-11-19  4:59     ` Austin Clements
2011-11-19  5:26       ` Dmitry Kurochkin
2011-11-19 18:58         ` Austin Clements
2011-11-20 18:52           ` Dmitry Kurochkin
2011-11-19 10:49     ` Jameson Graef Rollins
2011-11-20 18:32       ` Dmitry Kurochkin
2011-11-20 20:10         ` Jameson Graef Rollins
2011-11-23  3:40           ` Austin Clements
2012-01-12 17:07             ` Pieter Praet
2012-01-12 17:28               ` Austin Clements
2012-01-14  9:19                 ` Pieter Praet
2012-01-15 11:52                   ` David Edmondson
2012-01-15 17:58                     ` Austin Clements [this message]
2012-01-16  8:49                       ` David Edmondson
2012-01-16 13:18                         ` Tomi Ollila
2011-11-19  4:18 ` [PATCH v2] " Dmitry Kurochkin
2011-11-19 12:59   ` David Bremner
2011-11-20 18:35     ` Dmitry Kurochkin
2012-01-12 17:08       ` Pieter Praet
2012-01-13  3:16         ` David Bremner
2012-01-14  8:59           ` Pieter Praet

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://notmuchmail.org/

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

  git send-email \
    --in-reply-to=87boq4q23z.fsf@awakening.csail.mit.edu \
    --to=amdragon@mit.edu \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    --cc=pieter@praet.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

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).