From: Peter Wang <novalazy@gmail.com>
To: Austin Clements <amdragon@MIT.EDU>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH 1/4] show: indicate length of omitted body content (json)
Date: Tue, 7 Aug 2012 23:24:14 +1000 [thread overview]
Message-ID: <20120807232414.GA22132@hili.localdomain> (raw)
In-Reply-To: <20120806164710.GK22601@mit.edu>
On Mon, 6 Aug 2012 12:47:10 -0400, Austin Clements <amdragon@MIT.EDU> wrote:
> What's the overall goal of adding this? Are you planning to add size
> information to one of the frontends?
Yes, to my frontend.
>> > diff --git a/devel/schemata b/devel/schemata
> > index 9cb25f5..3df2764 100644
> > --- a/devel/schemata
> > +++ b/devel/schemata
> > @@ -69,7 +69,10 @@ part = {
> > # A leaf part's body content is optional, but may be included if
> > # it can be correctly encoded as a string. Consumers should use
> > # this in preference to fetching the part content separately.
> > - content?: string
> > + content?: string,
> > + # If a leaf part's body content is not included, the content-length
> > + # may be included instead.
>
> You mentioned elsewhere that the content-length returned is an
> estimate. If that's the case, this comment should say as much. Is it
> actually the case, though? g_mime_part_get_content_object is
> remarkably poorly documented for such an important function, but based
> on format_part_raw, it seems like the content-length your code returns
> will be exactly the number of bytes returned by the raw format for a
> leaf part.
It's the exact length of the _encoded_ content. If the transfer
encoding is base64, multiplying by 3/4 will get a close estimate of the
decoded content length. I assume quoted-printable encoding would only
be used if the content is mostly ASCII, so the encoded length can serve
as the estimated decoded length then.
> > diff --git a/notmuch-show.c b/notmuch-show.c
> > index 3556293..5c54257 100644
> > --- a/notmuch-show.c
> > +++ b/notmuch-show.c
> > @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
> > sp->map_key (sp, "content");
> > sp->string_len (sp, (char *) part_content->data, part_content->len);
> > g_object_unref (stream_memory);
> > + } else {
> > + GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part));
> > + GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);
> > + ssize_t length = g_mime_stream_length (stream);
> > + if (length >= 0) {
> > + sp->map_key (sp, "content-length");
> > + sp->integer (sp, length);
> > + }
>
> Do wrapper or stream need to be g_object_unref'd?
No.
> Any idea what the performance overhead of this is? I'm just curious.
> It might be approximately nothing, since GMime's parser is eager.
The start and end bounds of the stream are already known so there's
approximately nothing for g_mime_stream_length to do. The other
functions simply return field values.
I'll drop the changes for text output.
Peter
next prev parent reply other threads:[~2012-08-07 13:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-05 7:22 [PATCH 1/4] show: indicate length of omitted body content (json) Peter Wang
2012-08-05 7:22 ` [PATCH 2/4] test: conform to content-length fields (json) Peter Wang
2012-08-05 7:22 ` [PATCH 3/4] show: indicate length of omitted body content (text) Peter Wang
2012-08-06 16:50 ` Austin Clements
2012-08-05 7:22 ` [PATCH 4/4] test: conform to content-length fields (text) Peter Wang
2012-08-05 9:32 ` [PATCH 1/4] show: indicate length of omitted body content (json) Tomi Ollila
2012-08-05 21:37 ` Jameson Graef Rollins
2012-08-06 14:36 ` Peter Wang
2012-08-06 16:47 ` Austin Clements
2012-08-07 13:24 ` Peter Wang [this message]
2012-08-07 13:57 ` Austin Clements
2012-08-07 23:01 ` Mark Walters
2012-08-08 12:31 ` Peter Wang
2012-10-20 1:56 ` Ethan Glasser-Camp
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=20120807232414.GA22132@hili.localdomain \
--to=novalazy@gmail.com \
--cc=amdragon@MIT.EDU \
--cc=notmuch@notmuchmail.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).