Skip to content

Commit feef517

Browse files
committed
Fix #325 - Clarify get[Int|Date]Header() behaviour for multiple headers
This explicitly aligns the behaviour of these headers with the behaviour of getHeader().
1 parent b36d632 commit feef517

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

api/src/main/java/jakarta/servlet/http/HttpServletRequest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021 Oracle and/or its affiliates and others.
2+
* Copyright (c) 1997, 2022 Oracle and/or its affiliates and others.
33
* All rights reserved.
44
* Copyright 2004 The Apache Software Foundation
55
*
@@ -85,8 +85,9 @@ public interface HttpServletRequest extends ServletRequest {
8585
* The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.
8686
*
8787
* <p>
88-
* If the request did not have a header of the specified name, this method returns -1. If the header can't be converted
89-
* to a date, the method throws an <code>IllegalArgumentException</code>.
88+
* If the request did not have a header of the specified name, this method returns -1. If there are multiple headers
89+
* with the same name, this method returns the value of the first header in the request. If the header can't be
90+
* converted to a date, the method throws an <code>IllegalArgumentException</code>.
9091
*
9192
* @param name a <code>String</code> specifying the name of the header
9293
*
@@ -100,8 +101,8 @@ public interface HttpServletRequest extends ServletRequest {
100101
/**
101102
* Returns the value of the specified request header as a <code>String</code>. If the request did not include a header
102103
* of the specified name, this method returns <code>null</code>. If there are multiple headers with the same name, this
103-
* method returns the first head in the request. The header name is case insensitive. You can use this method with any
104-
* request header.
104+
* method returns the value of the first header in the request. The header name is case insensitive. You can use this
105+
* method with any request header.
105106
*
106107
* @param name a <code>String</code> specifying the header name
107108
*
@@ -144,7 +145,8 @@ public interface HttpServletRequest extends ServletRequest {
144145

145146
/**
146147
* Returns the value of the specified request header as an <code>int</code>. If the request does not have a header of
147-
* the specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a
148+
* the specified name, this method returns -1. If there are multiple headers with the same name, this method returns the
149+
* value of the first header in the request. If the header cannot be converted to an integer, this method throws a
148150
* <code>NumberFormatException</code>.
149151
*
150152
* <p>

spec/src/main/asciidoc/servlet-spec-body.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8548,6 +8548,11 @@ link:https://github.com/eclipse-ee4j/servlet-api/issues/164[Issue 164]::
85488548
Clarify Javadoc for `ServletResponse` and `HttpServletResponse` methods that are
85498549
NO-OPs once the response has been committed.
85508550

8551+
link:https://github.com/eclipse-ee4j/servlet-api/issues/325[Issue 325]::
8552+
Clarify the behaviour of `getDateHeader()` and `getIntHeader()` when multiple
8553+
headers with the same name are present in the `HttpServletRequest`. The expected
8554+
behaviour is aligned with `getHeader()`.
8555+
85518556
link:https://github.com/eclipse-ee4j/servlet-api/issues/463[Issue 463]::
85528557
Clarify Javadoc for `MultipartConfigElement` and `MultipartConfig` that sizes
85538558
are in bytes.

0 commit comments

Comments
 (0)