Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove/overwrite header in MockHttpServletRequest [SPR-17288] #21821

Closed
spring-projects-issues opened this issue Sep 19, 2018 · 4 comments
Closed
Assignees
Labels
in: test in: web status: duplicate type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Sep 19, 2018

Christopher Smith opened SPR-17288 and commented

MockHttpServletRequest supports adding arbitrary headers, but subsequent calls to addHeader always append the new values. While the internal doAddHeaderValue takes a boolean to specify replacement, it's not visible externally. When using the class for testing, it is often useful to construct it with the usual headers in a setup method, but there's no way to then overwrite a header per-test.

It would be useful to be able to remove an existing header from the request (either to leave it missing or to then replace it with a new value).


Affects: 4.3.19

Issue Links:

  • #21828 Support for removeHeader in MockHttpServletRequest
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 24, 2018

Rossen Stoyanchev commented

#21828 added removeHeader recently that should give you the ability to remove and before adding.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 24, 2018

Christopher Smith commented

That looks like what I was asking for; didn't find it in search for some reason. It looks like a fairly simple change; could we get a backport to 4.3?

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 24, 2018

Rossen Stoyanchev commented

Please add a comment under #21828.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 24, 2018

Rossen Stoyanchev commented

Resolving in favor of  #21828.

@spring-projects-issues spring-projects-issues added in: test type: enhancement status: duplicate in: web labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test in: web status: duplicate type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants