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

Spring MVC Test support for expectations on multivalue response headers [SPR-10087] #14720

Closed
spring-projects-issues opened this issue Dec 9, 2012 · 1 comment
Assignees
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Rick Mann opened SPR-10087 and commented

I'm not sure if the problem lies in the -test-mvc or -webmvc (or both).

In my webapp I build an HTTP response by calling HttpHeaders.add() twice with the same header and two different values. The resulting response on the wire contains this:

Vary: foo
Vary: bar

HTTP/1.1 allows this, but requires that it be possible to combine them into a single header field:

Vary: foo, bar

Unfortunately, the HeaderResultMatcher does not take the possibility of multiple headers into consideration when testing for the presence of a header:

https://github.com/SpringSource/spring-test-mvc/blob/master/src/main/java/org/springframework/test/web/server/result/HeaderResultMatchers.java

Line 49 should call getHeaders() and iterate through all the available results.

Alternatively, if ResponseEntity and HttpHeaders collaborated to combine multiple headers with the same name onto a single line, then a containsString() test would be sufficient to work around this problem.


Affects: 3.2 RC2, 4.2.4

Referenced from: commits 952a317

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

Line 49 should call getHeaders() and iterate through all the available results.

To do that the method should also accept a Matcher for a List. We could add additional methods (e.g. "strings" and "stringValues") to do this.

@spring-projects-issues spring-projects-issues added in: test Issues in the test module type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants