Non-String header values

Hi,

when mentioning that HTTP header values are ISO-Latin-1 as per HTTP/1.1 spec (and that I see issues w/ using String due to potential legacy-encoding-pain, e.g. with form uploads), Johannes pointed me to this:

  RFC 7230: Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing

  Historically, HTTP has allowed field content with text in the ISO-8859-1 charset
  .. A recipient SHOULD treat other ***octets*** in field
  content (obs-text) as ***opaque data***.

or in other words, something like this:

  var headers : [ String : String ]

should actually be

  var headers : [ String : Data ]

which of course is inconvenient. Someone already mentioned the idea of using different value types for the header values, which I think is a good idea for various reasons. I first thought maybe an enum

  enum HTTPHeaderValue {
    case string(String)
    case octets(Data)
    case int(Int)
    case mimeType(MediaType)
  }

but then the type is really is attached to the specific header, so I’m a little back to also using enums for headers:

  enum HTTPHeader {
    case contentLength(Int)
    case contentType(MediaType)
    case accept([MediaTypePattern])
    ...
    case other(String, Data) // name, value
  }
  var headers : [ HTTPHeader ]

Just an idea.

hh