Spring-framework: In contrast to the Javadoc, ServerHttpRequest.Builder implementation does not override headers

Created on 23 Jul 2019  路  4Comments  路  Source: spring-projects/spring-framework

Most helpful comment

It seems unlikely for code to depend on adding a header when mutating a server request. That probably explains the original Javadoc. So I think we should fix the behavior. However to make it a little less disruptive we could add a new method in 5.1.x:

/**
 * Set or override the specified header value(s).
 */
Builder header(String key, String... value);

Then deprecate the existing one in 5.1.x and remove it in 5.2 since having the two side by side is inconsistent and limiting (one adds, the other sets, no way to set with one, etc.), so we don't want a prolonged period of keeping them side by side.

All 4 comments

Thanks for pointing out that inconsistency. We'll look into it.

Related commit: a1ae9ac1bdd6aaaceb42c2a65b37ed92450334cc

We should fix the javadoc since this method is only about adding a header value.
Developers can mutate existing headers with headers(Consumer<HttpHeaders> headersConsumer).

It seems unlikely for code to depend on adding a header when mutating a server request. That probably explains the original Javadoc. So I think we should fix the behavior. However to make it a little less disruptive we could add a new method in 5.1.x:

/**
 * Set or override the specified header value(s).
 */
Builder header(String key, String... value);

Then deprecate the existing one in 5.1.x and remove it in 5.2 since having the two side by side is inconsistent and limiting (one adds, the other sets, no way to set with one, etc.), so we don't want a prolonged period of keeping them side by side.

Was this page helpful?
0 / 5 - 0 ratings