Skip to content

Allow iteration over headers, and enable multiple headers of a name #19

@nicholastmosher

Description

@nicholastmosher

Hi there. I'm trying to convert to and from the http crate Request and Response types while actually sending the request through an embedded_svc::http::client::Client instance. I noticed while trying to rebuild the response that embedded_svc::http::Headers trait's API does not provide an iterator over header/value pairs, but rather provides a "key lookup" style API, e.g. let header = response.header("header name"). I have a few questions about this:

  • According to the http spec, it is possible for a request or response to have multiple headers with the same name (https://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.4.2.p.4). However, having a "lookup" style API like this one seems to imply that each header name will only have one value. Would it be feasible to define (perhaps in a new trait) an iterator-style API that is capable of yielding multiple entries for the same header name?
  • In current known implementations of the Headers trait, does it simply return a comma-separated string to indicate multiple values for the given header? Or are multiple values by the same header name silently dropped?
  • With the current Headers trait, is there any way to enumerate all of the names of headers in a response? It seems not.

I think that the http crate does a really good job at capturing the nuances of the http protocol, so it'd be nice if the http traits here were expressive enough to allow for a full round-trip conversion without loss of information (for suitable body types).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions