You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/02/25 19:38:04 UTC

[tomcat] branch master updated: BZ 64166. HttpServletResponse.getHeaderNames() now returns unique names

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new e9ee933  BZ 64166. HttpServletResponse.getHeaderNames() now returns unique names
e9ee933 is described below

commit e9ee9338f3b4c694b7fd90b69ed468dbdeff5a76
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Feb 25 14:16:44 2020 +0000

    BZ 64166. HttpServletResponse.getHeaderNames() now returns unique names
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=64166
---
 java/org/apache/catalina/connector/Response.java | 7 ++++---
 webapps/docs/changelog.xml                       | 4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java
index fce5570..9ec0b5d 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -30,9 +30,11 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Enumeration;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 import java.util.function.Supplier;
 
 import jakarta.servlet.ServletOutputStream;
@@ -868,9 +870,8 @@ public class Response implements HttpServletResponse {
 
     @Override
     public Collection<String> getHeaders(String name) {
-        Enumeration<String> enumeration =
-                getCoyoteResponse().getMimeHeaders().values(name);
-        List<String> result = new ArrayList<>();
+        Enumeration<String> enumeration = getCoyoteResponse().getMimeHeaders().values(name);
+        Set<String> result = new LinkedHashSet<>();
         while (enumeration.hasMoreElements()) {
             result.add(enumeration.nextElement());
         }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5632768..dd93f38 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -59,6 +59,10 @@
         Add extension point to DeltaSession to improve subclassing.
         Patch provided by ThStock. (schultz)
       </add>
+      <fix>
+        <bug>64166</bug>: Ensure that the names returned by
+        <code>HttpServletResponse.getHeaderNames()</code> are unique. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch master updated: BZ 64166. HttpServletResponse.getHeaderNames() now returns unique names

Posted by Mark Thomas <ma...@apache.org>.
On 25/02/2020 20:47, Christopher Schultz wrote:
> Mark,
> 
> On 2/25/20 14:38, markt@apache.org wrote:
>> This is an automated email from the ASF dual-hosted git
>> repository.
> 
>> markt pushed a commit to branch master in repository
>> https://gitbox.apache.org/repos/asf/tomcat.git
> 
> 
>> The following commit(s) were added to refs/heads/master by this
>> push: new e9ee933  BZ 64166. HttpServletResponse.getHeaderNames()
>> now returns unique names e9ee933 is described below
> 
>> commit e9ee9338f3b4c694b7fd90b69ed468dbdeff5a76 Author: Mark Thomas
>> <ma...@apache.org> AuthorDate: Tue Feb 25 14:16:44 2020 +0000
> 
>> BZ 64166. HttpServletResponse.getHeaderNames() now returns unique
>> names
> 
>> https://bz.apache.org/bugzilla/show_bug.cgi?id=64166 ---
>> java/org/apache/catalina/connector/Response.java | 7 ++++---
>> webapps/docs/changelog.xml                       | 4 ++++ 2 files
>> changed, 8 insertions(+), 3 deletions(-)
> 
>> diff --git a/java/org/apache/catalina/connector/Response.java
>> b/java/org/apache/catalina/connector/Response.java index
>> fce5570..9ec0b5d 100644 ---
>> a/java/org/apache/catalina/connector/Response.java +++
>> b/java/org/apache/catalina/connector/Response.java @@ -30,9 +30,11
>> @@ import java.util.ArrayList; import java.util.Arrays; import
>> java.util.Collection; import java.util.Enumeration; +import
>> java.util.LinkedHashSet;
> 
> Is header order actually important?

Probably not but it might be for custom headers. I didn't want to change
the order to be on the safe side.

Mark


> AFAICT, the only time order matters is when header[0] is used for
> "status code" which is not uncommon, but weird.
> 
>> import java.util.List; import java.util.Locale; import
>> java.util.Map; +import java.util.Set; import
>> java.util.function.Supplier;
> 
>> import jakarta.servlet.ServletOutputStream; @@ -868,9 +870,8 @@
>> public class Response implements HttpServletResponse {
> 
>> @Override public Collection<String> getHeaders(String name) { -
>> Enumeration<String> enumeration = -
>> getCoyoteResponse().getMimeHeaders().values(name); -
>> List<String> result = new ArrayList<>(); +
>> Enumeration<String> enumeration =
>> getCoyoteResponse().getMimeHeaders().values(name); +
>> Set<String> result = new LinkedHashSet<>(); while
>> (enumeration.hasMoreElements()) {
>> result.add(enumeration.nextElement()); } diff --git
>> a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index
>> 5632768..dd93f38 100644 --- a/webapps/docs/changelog.xml +++
>> b/webapps/docs/changelog.xml @@ -59,6 +59,10 @@ Add extension point
>> to DeltaSession to improve subclassing. Patch provided by ThStock.
>> (schultz) </add> +      <fix> +        <bug>64166</bug>: Ensure
>> that the names returned by +
>> <code>HttpServletResponse.getHeaderNames()</code> are unique.
>> (markt) +      </fix> </changelog> </subsection> <subsection
>> name="Coyote">
> 
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch master updated: BZ 64166. HttpServletResponse.getHeaderNames() now returns unique names

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 2/25/20 14:38, markt@apache.org wrote:
> This is an automated email from the ASF dual-hosted git
> repository.
>
> markt pushed a commit to branch master in repository
> https://gitbox.apache.org/repos/asf/tomcat.git
>
>
> The following commit(s) were added to refs/heads/master by this
> push: new e9ee933  BZ 64166. HttpServletResponse.getHeaderNames()
> now returns unique names e9ee933 is described below
>
> commit e9ee9338f3b4c694b7fd90b69ed468dbdeff5a76 Author: Mark Thomas
> <ma...@apache.org> AuthorDate: Tue Feb 25 14:16:44 2020 +0000
>
> BZ 64166. HttpServletResponse.getHeaderNames() now returns unique
> names
>
> https://bz.apache.org/bugzilla/show_bug.cgi?id=64166 ---
> java/org/apache/catalina/connector/Response.java | 7 ++++---
> webapps/docs/changelog.xml                       | 4 ++++ 2 files
> changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/java/org/apache/catalina/connector/Response.java
> b/java/org/apache/catalina/connector/Response.java index
> fce5570..9ec0b5d 100644 ---
> a/java/org/apache/catalina/connector/Response.java +++
> b/java/org/apache/catalina/connector/Response.java @@ -30,9 +30,11
> @@ import java.util.ArrayList; import java.util.Arrays; import
> java.util.Collection; import java.util.Enumeration; +import
> java.util.LinkedHashSet;

Is header order actually important?

AFAICT, the only time order matters is when header[0] is used for
"status code" which is not uncommon, but weird.

> import java.util.List; import java.util.Locale; import
> java.util.Map; +import java.util.Set; import
> java.util.function.Supplier;
>
> import jakarta.servlet.ServletOutputStream; @@ -868,9 +870,8 @@
> public class Response implements HttpServletResponse {
>
> @Override public Collection<String> getHeaders(String name) { -
> Enumeration<String> enumeration = -
> getCoyoteResponse().getMimeHeaders().values(name); -
> List<String> result = new ArrayList<>(); +
> Enumeration<String> enumeration =
> getCoyoteResponse().getMimeHeaders().values(name); +
> Set<String> result = new LinkedHashSet<>(); while
> (enumeration.hasMoreElements()) {
> result.add(enumeration.nextElement()); } diff --git
> a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index
> 5632768..dd93f38 100644 --- a/webapps/docs/changelog.xml +++
> b/webapps/docs/changelog.xml @@ -59,6 +59,10 @@ Add extension point
> to DeltaSession to improve subclassing. Patch provided by ThStock.
> (schultz) </add> +      <fix> +        <bug>64166</bug>: Ensure
> that the names returned by +
> <code>HttpServletResponse.getHeaderNames()</code> are unique.
> (markt) +      </fix> </changelog> </subsection> <subsection
> name="Coyote">

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5Vh+EACgkQHPApP6U8
pFgXEg//S4fdqm8lAkbkQbgajds/S093BEqCXNih0aMecZgoc6EQWLXElFwnVML2
jSN4qEWlhnTHBW9i+Wt/z5FjJz5CTZpQbYYgAfKfXhC8Gg0uGoFdmpx805l4Rnhp
il9ftP6x5ZhcBkEzhUfevixsqHn8ntDyCP1kocCSrul+nXmUdgW+FFJQdDy94ec0
nS8h8koiFnY7EyFCH4a3SqC4d8ih5Z2ELi//PjfOIfCcIVblaQoKX4ZRxQsoLtYn
oW5cYBqKpRjpKQJmN2RKMkl9KCsqhVBLc0b8nHg6YZnurbnnRh2XkNJLIVY8WL1R
wDTXuQUX0n9bGQaVCkc/kYjirUlL/3xRbnyc1C4QVFMQcOUIcv9nWbjGm/iiDVib
jKlAUvXweO9ETJZnDKUBuo4hzHzKto2IiswzJ6FIVY4/QYy32ZtOUhunOc+XAndA
TvUldqY34LK0GcNvzRmBvjlXyqJTRSOsyTKYMc1gR27W/m7YBUm9AE0erz6ranEb
uZPtnTq8VLUIUrBmkJC4zV1eC3qxi8pNBGJq+gvQ8v7zmJCjenRxkPuHReJLmkZT
ex3Wvvqbs+xqncWUAAWhJ361kHmkGJz+xFeUrRJ3DDp4tXQpzuZI20Lmq0saOkx/
RTnjAwvcX66eJrOoXI7KSlUagg6IG3TCVeRrOoIxXSa2KU25+wE=
=4vzQ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org