chriso/klein.php — pull request #259 by Rican7 (2014-11-09 23:34:49+00:00)
Title: Feature - Configurable header normalization

This PR resolves #191 and is a response to the discussion there.

This PR introduces the ability to configure how the `HeaderDataCollection` normalizes header keys by simply passing in flags during construction or in the class' setter method `setNormalization()`.

This PR also changes how the `HeaderDataCollection` normalizes header names by default. As mentioned in the related issue, headers will now be normalized to their canonical MIME header format. While this technically won't change the way the data is accessed, it'll make their external representation more consistent with server/client norms.

Instead of lower-casing the header name, as we were before, the header name will instead be converted according to the same rules as Go's [`textproto.CanonicalMIMEHeaderKey(string)`][go-net-textproto-canonicalmimeheaderkey] function:

> CanonicalMIMEHeaderKey returns the canonical format of the MIME header key s. The canonicalization converts the first letter and any letter following a hyphen to upper case; the rest are converted to lowercase. For example, the canonical key for "accept-encoding" is "Accept-Encoding". MIME header keys are assumed to be ASCII only.

[go-net-textproto-canonicalmimeheaderkey]: http://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey