--- /dev/null
+Return-Path: <novalazy@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 967CF431FC4\r
+ for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 05:28:25 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id FD9d60CSRvMX for <notmuch@notmuchmail.org>;\r
+ Wed, 8 Aug 2012 05:28:24 -0700 (PDT)\r
+Received: from mail-yw0-f53.google.com (mail-yw0-f53.google.com\r
+ [209.85.213.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id C0C37431FBD\r
+ for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 05:28:24 -0700 (PDT)\r
+Received: by yhp3 with SMTP id 3so871195yhp.26\r
+ for <notmuch@notmuchmail.org>; Wed, 08 Aug 2012 05:28:24 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=+6el5QPikyaRHb8vgWyrFFSMafDBv36k5Jubb3Yx4G4=;\r
+ b=oCmcSjoF+2YaYXUFY1lzbl6YHZf5bewvmSInt05OzN/0wvvHFcwHejnaiU47XLAuac\r
+ XopjBoAgfjoxbCCGUaa3/oEGh+nXynJfTRW+VFQg/61ammxqGyAh3snxN+HNA52jKoXO\r
+ NB5/S1zaRvu4Y9H+vUo97sY0kjxFaXbdr9XwTjDYOiCdr1Z4aOgXpLgb6+/jzN2gb4kl\r
+ LA9tqAysMNifyaN43LkcFv0JKkXJUQV4Xxyzneh9LdiD/neTBwOeW0soEx0nB0UlqmqV\r
+ 9P3tqG5lLkcEHcmAUguAvKmGWYN8eN5kS3YzCG5NK91Ml6h6hI8MS09riCjcBfxM0qt1\r
+ 17rQ==\r
+Received: by 10.66.74.67 with SMTP id r3mr16407380pav.1.1344428903822;\r
+ Wed, 08 Aug 2012 05:28:23 -0700 (PDT)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+ [220.233.42.215])\r
+ by mx.google.com with ESMTPS id ng8sm13320094pbc.13.2012.08.08.05.28.21\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 08 Aug 2012 05:28:22 -0700 (PDT)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 2/3] show: indicate length, encoding of omitted body\r
+ content\r
+Date: Wed, 8 Aug 2012 22:27:51 +1000\r
+Message-Id: <1344428872-12374-3-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.4.4\r
+In-Reply-To: <1344428872-12374-1-git-send-email-novalazy@gmail.com>\r
+References: <1344428872-12374-1-git-send-email-novalazy@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 08 Aug 2012 12:28:25 -0000\r
+\r
+If a leaf part's body content is omitted, return the encoded length and\r
+transfer encoding in --format=json output. This information may be used\r
+by the consumer, e.g. to decide whether to download a large attachment\r
+over a slow link.\r
+\r
+Returning the _encoded_ content length is more efficient than returning\r
+the _decoded_ content length. Returning the transfer encoding allows\r
+the consumer to estimate the decoded content length.\r
+---\r
+ devel/schemata | 9 ++++++++-\r
+ notmuch-show.c | 14 ++++++++++++++\r
+ 2 files changed, 22 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/devel/schemata b/devel/schemata\r
+index 9cb25f5..094b9a5 100644\r
+--- a/devel/schemata\r
++++ b/devel/schemata\r
+@@ -69,7 +69,14 @@ part = {\r
+ # A leaf part's body content is optional, but may be included if\r
+ # it can be correctly encoded as a string. Consumers should use\r
+ # this in preference to fetching the part content separately.\r
+- content?: string\r
++ content?: string,\r
++ # If a leaf part's body content is not included, the length of\r
++ # the encoded content (in bytes) may be given instead.\r
++ content-length?: int,\r
++ # If a leaf part's body content is not included, its transfer encoding\r
++ # may be given. Using this and the encoded content length, it is\r
++ # possible for the consumer to estimate the decoded content length.\r
++ content-transfer-encoding?: string\r
+ }\r
+ \r
+ # The headers of a message or part (format_headers_json with reply = FALSE)\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 3556293..83535c7 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -664,6 +664,20 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+ sp->map_key (sp, "content");\r
+ sp->string_len (sp, (char *) part_content->data, part_content->len);\r
+ g_object_unref (stream_memory);\r
++ } else {\r
++ GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part));\r
++ GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);\r
++ ssize_t length = g_mime_stream_length (stream);\r
++ const char *cte = g_mime_object_get_header (meta, "content-transfer-encoding");\r
++\r
++ if (length >= 0) {\r
++ sp->map_key (sp, "content-length");\r
++ sp->integer (sp, length);\r
++ }\r
++ if (cte) {\r
++ sp->map_key (sp, "content-transfer-encoding");\r
++ sp->string (sp, cte);\r
++ }\r
+ }\r
+ } else if (GMIME_IS_MULTIPART (node->part)) {\r
+ sp->map_key (sp, "content");\r
+-- \r
+1.7.4.4\r
+\r