You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SimpleClientHttpRequestFactory: headers with null values should be sent as empty Strings [SPR-13225] #17816
RestTemplate+SimpleClientHttpRequestFactory:
All headers with null values are sent without colon.
Such requests are rejected by HAProxy(<BADREQ>).
BTW it's correctly processed in HttpComponentsClientHttpRequestFactory
I can see that a null header value is sent as an empty String with HttpComponentsClientHttpRequestFactory while the header is not sent at all with SimpleClientHttpRequestFactory. In both cases, the request is processed successfully.
For the record HttpComponentsClientHttpRequestFactory delegates to Apache HTTP components while SimpleClientHttpRequestFactory delegates to the JDK infrastructure (HttpURLConnection typically). The inconsistency I can see lies there anyway.
Since both requests are processed successfully for me, can you please clarify what you consider to be a bug?
headers are sent with SimpleClientHttpRequestFactory.
I caught traffic, so it looks like:
GET url HTTP/1.1
Accept: application/json
some-header
User-Agent: Java/1.7.0_60
Host: host
Connection: keep-alive
As you see there is no colon for the header with null value. It's processed in tomcat-server but rejected by HAProxy.
If you have difficulties with reproducing I can provide exact code.
Activity
spring-projects-issues commentedon Jul 13, 2015
Stéphane Nicoll commented
I can see that a
nullheader value is sent as an empty String withHttpComponentsClientHttpRequestFactorywhile the header is not sent at all withSimpleClientHttpRequestFactory. In both cases, the request is processed successfully.For the record
HttpComponentsClientHttpRequestFactorydelegates to Apache HTTP components whileSimpleClientHttpRequestFactorydelegates to the JDK infrastructure (HttpURLConnectiontypically). The inconsistency I can see lies there anyway.Since both requests are processed successfully for me, can you please clarify what you consider to be a bug?
spring-projects-issues commentedon Jul 13, 2015
Anatoly Deyneka commented
headers are sent with SimpleClientHttpRequestFactory.
I caught traffic, so it looks like:
GET url HTTP/1.1
Accept: application/json
some-header
User-Agent: Java/1.7.0_60
Host: host
Connection: keep-alive
As you see there is no colon for the header with null value. It's processed in tomcat-server but rejected by HAProxy.
If you have difficulties with reproducing I can provide exact code.
spring-projects-issues commentedon Jul 13, 2015
Stéphane Nicoll commented
The only thing I can think of would be to translate
nullto an empty String. This would be consistent with what Apache Commons does.spring-projects-issues commentedon Jul 13, 2015
Anatoly Deyneka commented
Yes, it will fix the problem.
I would expect fix here:
SimpleBufferingClientHttpRequest:104
spring-projects-issues commentedon Jul 14, 2015
Stéphane Nicoll commented
Done in master. Could you please give it a try against the next
4.2.0.BUILD-SNAPSHOT? (available in an hour or so). Thanks!