{"action":"created","comment":{"url":"https://api.github.com/repos/rackerlabs/repose/pulls/comments/40252893","id":40252893,"diff_hunk":"@@ -63,67 +76,275 @@ class HttpServletResponseWrapper(originalResponse: HttpServletResponse, headerMo\n   with HeaderInteractor {\n \n   /**\n-   * This constructor chains to the main constructor using the original responses output stream  as the last arguement.\n+   * This constructor chains to the main constructor using the original responses output stream  as the last argument.\n    *\n    * @constructor the constructor to use when you don't plan on using a custom stream for processing\n    * @param originalResponse the response to be wrapped\n-   * @param headerMode the mode to use for header accessiblity\n+   * @param headerMode the mode to use for header accessibility\n    * @param bodyMode the mode to use for body accessibility\n    */\n   def this(originalResponse: HttpServletResponse, headerMode: ResponseMode, bodyMode: ResponseMode) =\n     this(originalResponse, headerMode, bodyMode, originalResponse.getOutputStream)\n \n-  override def getHeaderNamesList: util.List[String] = ???\n+  object ResponseBodyType extends Enumeration {\n+    val Available, OutputStream, PrintWriter = Value\n+  }\n \n-  override def addHeader(headerName: String, headerValue: String, quality: Double): Unit = ???\n+  private val bodyOutputStream = bodyMode match {\n+    case ResponseMode.PASSTHROUGH => new PassthroughServletOutputStream(desiredOutputStream)\n+    case ResponseMode.READONLY => new ReadOnlyServletOutputStream(desiredOutputStream)\n+    case ResponseMode.MUTABLE => new MutableServletOutputStream(desiredOutputStream)\n+  }\n \n-  /**\n-   * @throws IllegalStateException when headerMode is anything other than ResponseMode.MUTABLE\n-   */\n-  override def appendHeader(headerName: String, headerValue: String): Unit = ???\n+  private val caseInsensitiveOrdering = Ordering.by[String, String](_.toLowerCase)\n+  private lazy val bodyPrintWriter = new PrintWriter(bodyOutputStream)\n+\n+  private var headerMap: Map[String, Seq[String]] = new TreeMap[String, Seq[String]]()(caseInsensitiveOrdering)\n+  private var responseBodyType = ResponseBodyType.Available\n+\n+  override def getResponse: ServletResponse = throw new UnsupportedOperationException(\"getResponse is not supported\")\n+\n+  override def setResponse(servletResponse: ServletResponse): Unit =\n+    throw new UnsupportedOperationException(\"setResponse is not supported\")\n+\n+  override def getHeaderNamesList: util.List[String] = getHeaderNames.toList\n+\n+  override def getHeaderNames: util.Collection[String] = headerMap.keys\n+\n+  override def containsHeader(name: String): Boolean = headerMap.contains(name)\n+\n+  override def getHeader(name: String): String = getHeaderValues(name).headOption.orNull\n+\n+  override def getHeaders(name: String): util.Collection[String] = getHeaderValues(name)\n+\n+  override def getHeadersList(name: String): util.List[String] = getHeaderValues(name)\n+\n+  override def getPreferredHeaders(name: String): util.List[String] = getPreferredHeaderValues(getHeaderValues(name))\n+\n+  override def getPreferredSplittableHeaders(name: String): util.List[String] =\n+    getPreferredHeaderValues(getSplittableHeaders(name))\n+\n+  override def getSplittableHeaders(name: String): util.List[String] =\n+    getHeaderValues(name).foldLeft(List.empty[String])((list, value) => list ++ value.split(\",\"))\n+\n+  override def addHeader(name: String, value: String): Unit = {\n+    headerMap = headerMap + (name -> (headerMap.getOrElse(name, Seq.empty[String]) :+ value))\n+\n+    if (headerMode != ResponseMode.MUTABLE) {\n+      // Write through to the wrapped response immediately\n+      super.addHeader(name, value)\n+    }\n+  }\n+\n+  override def addHeader(name: String, value: String, quality: Double): Unit =","path":"repose-aggregator/commons/utilities/src/main/scala/org/openrepose/commons/utils/servlet/http/HttpServletResponseWrapper.scala","position":124,"original_position":124,"commit_id":"934267b25f31660bc69cb96accaea08e162f8387","original_commit_id":"934267b25f31660bc69cb96accaea08e162f8387","user":{"login":"dmnjohns","id":1923408,"avatar_url":"https://avatars.githubusercontent.com/u/1923408?v=3","gravatar_id":"","url":"https://api.github.com/users/dmnjohns","html_url":"https://github.com/dmnjohns","followers_url":"https://api.github.com/users/dmnjohns/followers","following_url":"https://api.github.com/users/dmnjohns/following{/other_user}","gists_url":"https://api.github.com/users/dmnjohns/gists{/gist_id}","starred_url":"https://api.github.com/users/dmnjohns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmnjohns/subscriptions","organizations_url":"https://api.github.com/users/dmnjohns/orgs","repos_url":"https://api.github.com/users/dmnjohns/repos","events_url":"https://api.github.com/users/dmnjohns/events{/privacy}","received_events_url":"https://api.github.com/users/dmnjohns/received_events","type":"User","site_admin":false},"body":"I guess I'm leaning toward yes now, but you tell me.\r\n\r\nI will say that the q value according to HTTP spec only allows up to three decimal points. That limits the quality domain to 10^3 + 1 distinct values. Not range checking obviously expands that domain, but honestly, there should never be a need.\r\n\r\nOn the usage side, do we care what a user stick heres? Our code always just takes the highest value. If we do range check, do we through a compile time or runtime exception? In the former case, do I want to deal with that every time I call this code? Probably not. In the latter case, if I haven't tested my code very well I start getting exceptions at runtime. Is an invalid quality an unrecoverable exception? The HTTP spec does define a quality value as being in the range of 0 to 1, but it does not preclude the existence of a parameter named 'q' being used to convey any value in the general case.\r\n\r\nFor reference:\r\nhttp://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.9","created_at":"2015-09-23T20:24:32Z","updated_at":"2015-09-23T20:24:32Z","html_url":"https://github.com/rackerlabs/repose/pull/1374#discussion_r40252893","pull_request_url":"https://api.github.com/repos/rackerlabs/repose/pulls/1374","_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/repose/pulls/comments/40252893"},"html":{"href":"https://github.com/rackerlabs/repose/pull/1374#discussion_r40252893"},"pull_request":{"href":"https://api.github.com/repos/rackerlabs/repose/pulls/1374"}}},"pull_request":{"url":"https://api.github.com/repos/rackerlabs/repose/pulls/1374","id":45177453,"html_url":"https://github.com/rackerlabs/repose/pull/1374","diff_url":"https://github.com/rackerlabs/repose/pull/1374.diff","patch_url":"https://github.com/rackerlabs/repose/pull/1374.patch","issue_url":"https://api.github.com/repos/rackerlabs/repose/issues/1374","number":1374,"state":"open","locked":false,"title":"REP-2253 Servlet Response Wrapper","user":{"login":"dmnjohns","id":1923408,"avatar_url":"https://avatars.githubusercontent.com/u/1923408?v=3","gravatar_id":"","url":"https://api.github.com/users/dmnjohns","html_url":"https://github.com/dmnjohns","followers_url":"https://api.github.com/users/dmnjohns/followers","following_url":"https://api.github.com/users/dmnjohns/following{/other_user}","gists_url":"https://api.github.com/users/dmnjohns/gists{/gist_id}","starred_url":"https://api.github.com/users/dmnjohns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmnjohns/subscriptions","organizations_url":"https://api.github.com/users/dmnjohns/orgs","repos_url":"https://api.github.com/users/dmnjohns/repos","events_url":"https://api.github.com/users/dmnjohns/events{/privacy}","received_events_url":"https://api.github.com/users/dmnjohns/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-16T14:22:16Z","updated_at":"2015-09-23T20:24:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed345240a04f9a28db5126378e11120d8a64a434","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rackerlabs/repose/pulls/1374/commits","review_comments_url":"https://api.github.com/repos/rackerlabs/repose/pulls/1374/comments","review_comment_url":"https://api.github.com/repos/rackerlabs/repose/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rackerlabs/repose/issues/1374/comments","statuses_url":"https://api.github.com/repos/rackerlabs/repose/statuses/934267b25f31660bc69cb96accaea08e162f8387","head":{"label":"rackerlabs:REP-2253","ref":"REP-2253","sha":"934267b25f31660bc69cb96accaea08e162f8387","user":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":1981821,"name":"repose","full_name":"rackerlabs/repose","owner":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rackerlabs/repose","description":"The powerful, programmable, API Middleware Platform","fork":false,"url":"https://api.github.com/repos/rackerlabs/repose","forks_url":"https://api.github.com/repos/rackerlabs/repose/forks","keys_url":"https://api.github.com/repos/rackerlabs/repose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rackerlabs/repose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rackerlabs/repose/teams","hooks_url":"https://api.github.com/repos/rackerlabs/repose/hooks","issue_events_url":"https://api.github.com/repos/rackerlabs/repose/issues/events{/number}","events_url":"https://api.github.com/repos/rackerlabs/repose/events","assignees_url":"https://api.github.com/repos/rackerlabs/repose/assignees{/user}","branches_url":"https://api.github.com/repos/rackerlabs/repose/branches{/branch}","tags_url":"https://api.github.com/repos/rackerlabs/repose/tags","blobs_url":"https://api.github.com/repos/rackerlabs/repose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rackerlabs/repose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rackerlabs/repose/git/refs{/sha}","trees_url":"https://api.github.com/repos/rackerlabs/repose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rackerlabs/repose/statuses/{sha}","languages_url":"https://api.github.com/repos/rackerlabs/repose/languages","stargazers_url":"https://api.github.com/repos/rackerlabs/repose/stargazers","contributors_url":"https://api.github.com/repos/rackerlabs/repose/contributors","subscribers_url":"https://api.github.com/repos/rackerlabs/repose/subscribers","subscription_url":"https://api.github.com/repos/rackerlabs/repose/subscription","commits_url":"https://api.github.com/repos/rackerlabs/repose/commits{/sha}","git_commits_url":"https://api.github.com/repos/rackerlabs/repose/git/commits{/sha}","comments_url":"https://api.github.com/repos/rackerlabs/repose/comments{/number}","issue_comment_url":"https://api.github.com/repos/rackerlabs/repose/issues/comments{/number}","contents_url":"https://api.github.com/repos/rackerlabs/repose/contents/{+path}","compare_url":"https://api.github.com/repos/rackerlabs/repose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rackerlabs/repose/merges","archive_url":"https://api.github.com/repos/rackerlabs/repose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rackerlabs/repose/downloads","issues_url":"https://api.github.com/repos/rackerlabs/repose/issues{/number}","pulls_url":"https://api.github.com/repos/rackerlabs/repose/pulls{/number}","milestones_url":"https://api.github.com/repos/rackerlabs/repose/milestones{/number}","notifications_url":"https://api.github.com/repos/rackerlabs/repose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rackerlabs/repose/labels{/name}","releases_url":"https://api.github.com/repos/rackerlabs/repose/releases{/id}","created_at":"2011-07-01T04:39:34Z","updated_at":"2015-09-22T23:40:01Z","pushed_at":"2015-09-23T19:29:13Z","git_url":"git://github.com/rackerlabs/repose.git","ssh_url":"git@github.com:rackerlabs/repose.git","clone_url":"https://github.com/rackerlabs/repose.git","svn_url":"https://github.com/rackerlabs/repose","homepage":"http://www.openrepose.org/","size":119680,"stargazers_count":212,"watchers_count":212,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":57,"mirror_url":null,"open_issues_count":11,"forks":57,"open_issues":11,"watchers":212,"default_branch":"master"}},"base":{"label":"rackerlabs:master","ref":"master","sha":"eab6fc1e45a1eedf23165fa9eef5ea081647579e","user":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":1981821,"name":"repose","full_name":"rackerlabs/repose","owner":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rackerlabs/repose","description":"The powerful, programmable, API Middleware Platform","fork":false,"url":"https://api.github.com/repos/rackerlabs/repose","forks_url":"https://api.github.com/repos/rackerlabs/repose/forks","keys_url":"https://api.github.com/repos/rackerlabs/repose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rackerlabs/repose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rackerlabs/repose/teams","hooks_url":"https://api.github.com/repos/rackerlabs/repose/hooks","issue_events_url":"https://api.github.com/repos/rackerlabs/repose/issues/events{/number}","events_url":"https://api.github.com/repos/rackerlabs/repose/events","assignees_url":"https://api.github.com/repos/rackerlabs/repose/assignees{/user}","branches_url":"https://api.github.com/repos/rackerlabs/repose/branches{/branch}","tags_url":"https://api.github.com/repos/rackerlabs/repose/tags","blobs_url":"https://api.github.com/repos/rackerlabs/repose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rackerlabs/repose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rackerlabs/repose/git/refs{/sha}","trees_url":"https://api.github.com/repos/rackerlabs/repose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rackerlabs/repose/statuses/{sha}","languages_url":"https://api.github.com/repos/rackerlabs/repose/languages","stargazers_url":"https://api.github.com/repos/rackerlabs/repose/stargazers","contributors_url":"https://api.github.com/repos/rackerlabs/repose/contributors","subscribers_url":"https://api.github.com/repos/rackerlabs/repose/subscribers","subscription_url":"https://api.github.com/repos/rackerlabs/repose/subscription","commits_url":"https://api.github.com/repos/rackerlabs/repose/commits{/sha}","git_commits_url":"https://api.github.com/repos/rackerlabs/repose/git/commits{/sha}","comments_url":"https://api.github.com/repos/rackerlabs/repose/comments{/number}","issue_comment_url":"https://api.github.com/repos/rackerlabs/repose/issues/comments{/number}","contents_url":"https://api.github.com/repos/rackerlabs/repose/contents/{+path}","compare_url":"https://api.github.com/repos/rackerlabs/repose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rackerlabs/repose/merges","archive_url":"https://api.github.com/repos/rackerlabs/repose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rackerlabs/repose/downloads","issues_url":"https://api.github.com/repos/rackerlabs/repose/issues{/number}","pulls_url":"https://api.github.com/repos/rackerlabs/repose/pulls{/number}","milestones_url":"https://api.github.com/repos/rackerlabs/repose/milestones{/number}","notifications_url":"https://api.github.com/repos/rackerlabs/repose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rackerlabs/repose/labels{/name}","releases_url":"https://api.github.com/repos/rackerlabs/repose/releases{/id}","created_at":"2011-07-01T04:39:34Z","updated_at":"2015-09-22T23:40:01Z","pushed_at":"2015-09-23T19:29:13Z","git_url":"git://github.com/rackerlabs/repose.git","ssh_url":"git@github.com:rackerlabs/repose.git","clone_url":"https://github.com/rackerlabs/repose.git","svn_url":"https://github.com/rackerlabs/repose","homepage":"http://www.openrepose.org/","size":119680,"stargazers_count":212,"watchers_count":212,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":57,"mirror_url":null,"open_issues_count":11,"forks":57,"open_issues":11,"watchers":212,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/repose/pulls/1374"},"html":{"href":"https://github.com/rackerlabs/repose/pull/1374"},"issue":{"href":"https://api.github.com/repos/rackerlabs/repose/issues/1374"},"comments":{"href":"https://api.github.com/repos/rackerlabs/repose/issues/1374/comments"},"review_comments":{"href":"https://api.github.com/repos/rackerlabs/repose/pulls/1374/comments"},"review_comment":{"href":"https://api.github.com/repos/rackerlabs/repose/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rackerlabs/repose/pulls/1374/commits"},"statuses":{"href":"https://api.github.com/repos/rackerlabs/repose/statuses/934267b25f31660bc69cb96accaea08e162f8387"}}}}