couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Lehnardt (JIRA)" <>
Subject [jira] [Commented] (COUCHDB-1368) multipart/related document body doesn't identify which part is which attachment
Date Wed, 14 Nov 2012 18:06:12 GMT


Jan Lehnardt commented on COUCHDB-1368:

The main CouchDB repo lives here:;a=summary

Branches are not mirrored to GitHub at this point (sorry), but I pushed it to my fork:

The commit in question:

Here’s a request dump:

> curl -Nv $COUCH/test/asd?attachments=true -H "Accept: multipart/related,*/*;"
* About to connect() to port 5984 (#0)
*   Trying
* connected
* Connected to ( port 5984 (#0)
> GET /test/asd?attachments=true HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host:
> Accept: multipart/related,*/*;
< HTTP/1.1 200 OK
< Server: CouchDB/1.3.0a-b9af7ea-git (Erlang OTP/R15B02)
< ETag: "9-4310e4b1fcab6822344790d37fb5ddea"
< Date: Wed, 14 Nov 2012 18:04:57 GMT
< Content-Type: multipart/related; boundary="a38b2d614bb2a8d70e31050a0e2e11a5"
< Content-Length: 493
content-type: application/json

Content-ID: test.txt
Content-Type: text/plain
Content-Length: 30
Content-Transfer-Encoding: gzip



The closing boundary is off, I seem to have a bug in the main request’s Content-Length calculation,
but this is the direction this is going.
> multipart/related document body doesn't identify which part is which attachment
> -------------------------------------------------------------------------------
>                 Key: COUCHDB-1368
>                 URL:
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>            Reporter: Jens Alfke
>            Priority: Minor
> If you GET a document with attachments in multipart/related format (by adding ?attachments=true
and setting Accept:multipart/related), the MIME bodies for the attachments have no headers.
This makes it difficult to tell which one is which. Damien says they're in the same order
that they appear in the document's "_attachments" object ... which is fine if you're Erlang,
because Erlang preserves the order of keys in a JSON object, but no other JSON implementation
I know of does that (because they use hashtables instead of linked lists.)
> The upshot is that any non-Erlang code trying to parse such a response will have to do
some by-hand parsing of the JSON data to get the _attachment keys in order.
> This can be fixed by adding a "Content-ID" header to each attachment body, whose value
is the filename. It would be nice if other standard headers were added too, like "Content-Type",
"Content-Length", "Content-Encoding", as this would make it work better with existing MIME
multipart libraries.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message