shazow/urllib3 — pull request #363 by mythguided (2014-03-21 17:48:13+00:00)
Title: Make initial boundaries of multipart encoded form data compliant with RFC 1521

`urllib3.filepost.encode_multipart_formdata` is not fully compliant with [RFC 1521][rfc1521]; specifically, boundaries technically include `\r\n` at the start, which is omitted for the initial part in what that produces.

The portion of the RFC I'm talking about is in [RFC 1521][rfc1521], "MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies", Subsection 7.2.1 ("Multipart: The common syntax"), on page 30:
> Note that the encapsulation boundary must occur at the beginning of a
> line, i.e., following a CRLF, and that the initial CRLF is considered
> to be attached to the encapsulation boundary rather than part of the
> preceding part. The boundary must be followed immediately either by
> another CRLF and the header fields for the next part, or by two
> CRLFs, in which case there are no header fields for the next part
> (and it is therefore assumed to be of Content-Type text/plain).

Key part there is "the initial CRLF is considered to be attached to the encapsulation boundary rather than part of the preceding part."

[rfc1521]: https://www.ietf.org/rfc/rfc1521.txt