gallery.py: Rework headers to use an OrderedDict
authorW. Trevor King <wking@tremily.us>
Mon, 9 Dec 2013 05:17:06 +0000 (21:17 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 9 Dec 2013 05:17:06 +0000 (21:17 -0800)
commit1684b70942da8330b55bbdd8da25002bdae9e55a
treec40a12843115486f943e5d98c830f0862b44e2ee
parent3f35377f42d25fad5ffb2b4c541035b24d3a88c8
gallery.py: Rework headers to use an OrderedDict

This makes it easier to manipulate and access headers (e.g. to extract
the charset).  Also:

* Use CRLF line endings for headers [1], instead of our old LF.
* Encode text/ content to bytes (other content should already be in
  bytes) [2].  The encoding used for text/ content is configurable.

[1]: http://tools.ietf.org/html/rfc2616#section-6.1
[2]: http://www.python.org/dev/peps/pep-0333/#unicode-issues
posts/gallery/gallery.py