Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions