{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Common/issues/64","labels_url":"https://api.github.com/repos/aspnet/Common/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Common/issues/64/comments","events_url":"https://api.github.com/repos/aspnet/Common/issues/64/events","html_url":"https://github.com/aspnet/Common/issues/64","id":118115300,"number":64,"title":"Add a binary constant mode to StringValues","user":{"login":"lodejard","id":1693989,"avatar_url":"https://avatars.githubusercontent.com/u/1693989?v=3","gravatar_id":"","url":"https://api.github.com/users/lodejard","html_url":"https://github.com/lodejard","followers_url":"https://api.github.com/users/lodejard/followers","following_url":"https://api.github.com/users/lodejard/following{/other_user}","gists_url":"https://api.github.com/users/lodejard/gists{/gist_id}","starred_url":"https://api.github.com/users/lodejard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lodejard/subscriptions","organizations_url":"https://api.github.com/users/lodejard/orgs","repos_url":"https://api.github.com/users/lodejard/repos","events_url":"https://api.github.com/users/lodejard/events{/privacy}","received_events_url":"https://api.github.com/users/lodejard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-20T19:59:25Z","updated_at":"2015-11-20T20:30:30Z","closed_at":null,"body":"Something like the following\r\n```cs\r\n        public StringValues(string value, Encoding encoding)\r\n        {\r\n            _value = value;\r\n            _values = null;\r\n            _bytes = encoding.GetBytes(value);\r\n            _encoding = encoding;\r\n        }\r\n\r\n        public static StringValues CreateBinaryConstant(string value, Encoding encoding)\r\n        {\r\n            return new StringValues(value, encoding);\r\n        }\r\n\r\n        public bool TryGetBinaryConstant(out byte[] bytes, out Encoding encoding)\r\n        {\r\n            bytes = _bytes;\r\n            encoding = _encoding;\r\n            return _bytes != null;\r\n        }\r\n```\r\n\r\nwould enable an application to contain\r\n```\r\n  static readonly StringValues _textPlain = StringValues.CreateBinaryConstant(\"text/plain\", Encoding.ASCII);\r\n\r\n// and later\r\n    httpResponse.Headers[\"Content-Type\"] = _textPlain;\r\n```\r\n\r\nthis would enable a server to optimize the header output\r\n```\r\n  byte[] bytes; Encoding encoding;\r\n  if (theHeaderValues.TryGetBinaryConstant(out bytes, out encoding) && encoding == _ascii)\r\n  {\r\n    // blit \"\\r\\nThe-Header: \" \r\n    // blit {bytes}\r\n  }\r\n  else\r\n  {\r\n    foreach(var value in headerValues)\r\n    {\r\n      // blit \"\\r\\nThe-Header: \"\r\n      // ascii encode {value}\r\n    }\r\n  }\r\n```"},"comment":{"url":"https://api.github.com/repos/aspnet/Common/issues/comments/158516297","html_url":"https://github.com/aspnet/Common/issues/64#issuecomment-158516297","issue_url":"https://api.github.com/repos/aspnet/Common/issues/64","id":158516297,"user":{"login":"benaadams","id":1142958,"avatar_url":"https://avatars.githubusercontent.com/u/1142958?v=3","gravatar_id":"","url":"https://api.github.com/users/benaadams","html_url":"https://github.com/benaadams","followers_url":"https://api.github.com/users/benaadams/followers","following_url":"https://api.github.com/users/benaadams/following{/other_user}","gists_url":"https://api.github.com/users/benaadams/gists{/gist_id}","starred_url":"https://api.github.com/users/benaadams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benaadams/subscriptions","organizations_url":"https://api.github.com/users/benaadams/orgs","repos_url":"https://api.github.com/users/benaadams/repos","events_url":"https://api.github.com/users/benaadams/events{/privacy}","received_events_url":"https://api.github.com/users/benaadams/received_events","type":"User","site_admin":false},"created_at":"2015-11-20T20:30:30Z","updated_at":"2015-11-20T20:30:30Z","body":"Related https://github.com/aspnet/KestrelHttpServer/issues/169"}}