Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Clarify setHeader() and null or empty string arguments #159

Closed
glassfishrobot opened this issue Sep 2, 2016 · 5 comments
Closed

Clarify setHeader() and null or empty string arguments #159

glassfishrobot opened this issue Sep 2, 2016 · 5 comments
Assignees
Labels
Enhancement New feature or request Question Further information is requested

Comments

@glassfishrobot
Copy link

The spec for HttpServletResponse.setHeader() does not say what to do if one or both of the arguments is null or empty.

https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletResponse.html#setHeader-java.lang.String-java.lang.String-

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by @edburns

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
@edburns said:
setHeader(null, anything) is a no-op.
setHeader(anything, null) removes the header
setHeader(anything, "") makes the header "anything" have an empty value. If there is an existing value for header anything, that value is replaced with the empty value.

If a header has been removed in this way, containsHeader() for that header returns false.

containsHeader(null) always returns false.

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Add this text:

"Containers may still add or modify headers before the response is
committed. These will generally be headers that are required at a
protocol level."

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA SERVLET_SPEC-159

@glassfishrobot
Copy link
Author

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Enhancement New feature or request Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants