{"action":"created","issue":{"url":"https://api.github.com/repos/hyperium/http/issues/228","repository_url":"https://api.github.com/repos/hyperium/http","labels_url":"https://api.github.com/repos/hyperium/http/issues/228/labels{/name}","comments_url":"https://api.github.com/repos/hyperium/http/issues/228/comments","events_url":"https://api.github.com/repos/hyperium/http/issues/228/events","html_url":"https://github.com/hyperium/http/issues/228","id":341206394,"node_id":"MDU6SXNzdWUzNDEyMDYzOTQ=","number":228,"title":"X-<Header> converts to lowercase","user":{"login":"crusty-dave","id":41089818,"node_id":"MDQ6VXNlcjQxMDg5ODE4","avatar_url":"https://avatars3.githubusercontent.com/u/41089818?v=4","gravatar_id":"","url":"https://api.github.com/users/crusty-dave","html_url":"https://github.com/crusty-dave","followers_url":"https://api.github.com/users/crusty-dave/followers","following_url":"https://api.github.com/users/crusty-dave/following{/other_user}","gists_url":"https://api.github.com/users/crusty-dave/gists{/gist_id}","starred_url":"https://api.github.com/users/crusty-dave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crusty-dave/subscriptions","organizations_url":"https://api.github.com/users/crusty-dave/orgs","repos_url":"https://api.github.com/users/crusty-dave/repos","events_url":"https://api.github.com/users/crusty-dave/events{/privacy}","received_events_url":"https://api.github.com/users/crusty-dave/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-14T03:54:12Z","updated_at":"2018-07-14T04:02:32Z","closed_at":"2018-07-14T04:02:22Z","author_association":"NONE","body":"With the following code:\r\n\r\n`Ok(HttpResponse::Ok() .header(\"X-Subject-Token\", token.token) .body(\"\"))`\r\n\r\nIt transmits \"X-Subject-Token\" as \"x-subject-token\", this would seem to be a bug, it shouldn't be changing any header tags like this AFAIK?\r\n\r\nPer RFC 7230, the headers should be case-insensitive, but I would still expect http to honor the case that I have provided.\r\n\r\n[RFC 7230](https://tools.ietf.org/html/rfc7230#page-19)\r\n\r\n> 3.2. Header Fields\r\n> \r\n> Each header field consists of a case-insensitive field name followed\r\n> by a colon (\":\"), optional leading whitespace, the field value, and\r\n> optional trailing whitespace.\r\n> \r\n\r\nNote that the HTTP RFCs use camel-case with dash (-) separators when they describe the fields.\r\n\r\nThis is the first time that I have witnessed something like \"content-type\" instead of \"Content-Type\".\r\n\r\nI would think that this might cause some compatibility issues with some http processors if they ignored section 3.2 (I ran into some code with that issue).  So at the least, there should be an option to preserve Camel-Case if present IMO.\r\n"},"comment":{"url":"https://api.github.com/repos/hyperium/http/issues/comments/404996755","html_url":"https://github.com/hyperium/http/issues/228#issuecomment-404996755","issue_url":"https://api.github.com/repos/hyperium/http/issues/228","id":404996755,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDk5Njc1NQ==","user":{"login":"seanmonstar","id":51479,"node_id":"MDQ6VXNlcjUxNDc5","avatar_url":"https://avatars1.githubusercontent.com/u/51479?v=4","gravatar_id":"","url":"https://api.github.com/users/seanmonstar","html_url":"https://github.com/seanmonstar","followers_url":"https://api.github.com/users/seanmonstar/followers","following_url":"https://api.github.com/users/seanmonstar/following{/other_user}","gists_url":"https://api.github.com/users/seanmonstar/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmonstar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmonstar/subscriptions","organizations_url":"https://api.github.com/users/seanmonstar/orgs","repos_url":"https://api.github.com/users/seanmonstar/repos","events_url":"https://api.github.com/users/seanmonstar/events{/privacy}","received_events_url":"https://api.github.com/users/seanmonstar/received_events","type":"User","site_admin":false},"created_at":"2018-07-14T04:02:32Z","updated_at":"2018-07-14T04:02:32Z","author_association":"MEMBER","body":"As you've pointed out, RFC 7230 says names are case-insensitive, so *should* be perfectly valid to treat `X-Subject-Token` as `x-subject-token`. Additionally, in HTTP/2, **all** header names are lowercase (it's specified to be a protocol error for upper case names). Because of this, `HeaderName` chooses to always handle names as lower case. Doing this allows optimizations: case-insensitive hashing and comparison are no longer required, improving speed of inserts and searches in the `HeaderMap`.\r\n\r\nNotably, `HeaderName` is just an optimized holder of a header name string. HTTP implementations certainly can transform the name bytes to camel case before serializing to a network stream, For example, [hyper provides an option to do just that](https://docs.rs/hyper/0.12.*/hyper/client/struct.Builder.html#method.http1_title_case_headers), for when users actually do have to deal with bad HTTP implementations. In hyper, it isn't enabled by default, since there's a cost to transforming the bytes, and most HTTP implementations are good-ish, and handle header names correctly.\r\n\r\nYou could ask actix-web to provide such an option."}}
{"actor":{"display_login":"seanmonstar"}}