Commit Graph

592 Commits

Author SHA1 Message Date
Brian Clozel
323ccf99e5 Restrict HTTP methods on Servlet HiddenHttpMethodFilter
This commit restricts the allowed HTTP methods on HiddenHttpMethodFilter
(Servlet variant) to the following: PUT, DELETE, PATCH.

This filter is meant to be used to simulate those methods from HTML
forms sent by browsers, so no other methods are allowed.

Issue: SPR-16836
(Cherry-picked from f64fa3dea1)
2018-06-11 19:18:28 +02:00
Juergen Hoeller
289a6091f1 SimpleClientHttpResponse catches any Exception on close
Issue: SPR-16773

(cherry picked from commit 21fad8e)
2018-05-02 17:15:14 +02:00
Juergen Hoeller
bcda243f63 Polishing 2018-03-29 17:34:28 +02:00
Rossen Stoyanchev
6e4bbac6f7 MvcResult returns asyncResult after asyncDispatch
Issue: SPR-16648
2018-03-28 22:27:30 -04:00
Rossen Stoyanchev
2e4963fca3 Revert "Always specify charset for form data requests"
This reverts commit 1897d8e858.

Issue: SPR-16613
2018-03-28 11:58:24 -04:00
Juergen Hoeller
3b3f27d5ff DefaultResponseErrorHandler.hasError avoids exception for unknown status
Issue: SPR-16604
2018-03-28 11:42:43 +02:00
Rossen Stoyanchev
1897d8e858 Always specify charset for form data requests
Issue: SPR-16613
2018-03-27 20:04:53 -04:00
Juergen Hoeller
2cac3a8255 InterceptingClientHttpRequest adapts to StreamingHttpOutputMessage
Issue: SPR-16582

(cherry picked from commit 4173022)
2018-03-28 01:16:59 +02:00
Juergen Hoeller
caed04473e Consistent HttpMethod identity comparisons
(cherry picked from commit 0de36d2)
2018-02-18 22:28:37 +01:00
Juergen Hoeller
87abdb92da Polishing 2018-02-16 21:02:00 +01:00
Juergen Hoeller
6d11b40353 Consistent use of StringUtils.toStringArray 2018-02-16 19:48:43 +01:00
Rossen Stoyanchev
608ef46516 ForwardedHeaderFilter handles query+fragment correctly
Issue: SPR-16506
2018-02-16 12:41:23 -05:00
Juergen Hoeller
fd964ca4b1 Consistent object type exposure for JSON rendering (workaround for Gson)
Issue: SPR-16461

(cherry picked from commit 817a836)
2018-02-12 13:43:28 +01:00
Juergen Hoeller
04f954956c ServletServerHttpRequest.getURI() ignores malformed query string
The resolved URI instance is also being cached now. This should not make a difference in a real Servlet environment but does affect tests which assumed they could modify an HttpServletRequest path behind a pre-created ServletServerHttpRequest instance. Our WebSocket test base class has been revised accordingly, re-creating the ServletServerHttpRequest in such a case.

Issue: SPR-16414

(cherry picked from commit 0e6f8df)
2018-02-12 13:39:11 +01:00
Juergen Hoeller
c1bc74c83f ResponseEntityResponseExtractor tolerates unknown HTTP status codes
Issue: SPR-16371
2018-01-19 19:13:16 +01:00
Juergen Hoeller
f68fdd4454 Proper null path checks in HierarchicalUriComponents
Issue: SPR-16364
2018-01-19 19:13:06 +01:00
sdeleuze
1b3b058ebd Refine forwarded protocol support
This commit refines forwarded protocol support in order to support
proxies that only set "X-Forwarded-Proto" header and not
"X-Forwarded-Port" by performing a reset of the port in such case.

"Forwarded" header support has been updated accordingly since it
also supports similar use case, as described in SPR-15504.

Issue: SPR-16262
2018-01-09 14:56:23 +01:00
sdeleuze
e6e6b8f4ad Allow interceptors to add existing header values
Additional commit to provide support of requests
that have a body.

Issue: SPR-15066
2017-12-13 09:47:55 +01:00
sdeleuze
4b8a937bee Allow interceptors to add existing header values
Provide a fully mutable HttpHeaders to ClientHttpRequestInterceptors
of a RestTemplate when headers are set using HttpEntity. This avoids
UnsupportedOperationException if both HttpEntity and
ClientHttpRequestInterceptor add values for the same HTTP header.

Issue: SPR-15066
2017-12-11 17:56:48 +01:00
Juergen Hoeller
640c8ff693 Polishing 2017-11-14 12:31:01 +01:00
Juergen Hoeller
dc0a934c99 MockHttpServletResponse.getDateHeader returns -1 for non-existent header
Includes consistent getDateHeader results in both MockHttpServletResponse variants (spring-test and spring-web)

Issue: SPR-16160

(cherry picked from commit 80a0cf7)
2017-11-14 12:26:32 +01:00
Juergen Hoeller
9ca4de1ccf MockHttpServletRequest.getRequestURL aligns with getServerName/Port
Issue: SPR-16138

(cherry picked from commit 0edf4d6)
2017-11-14 12:25:55 +01:00
Rossen Stoyanchev
97bc2762e1 Handle errors via AsyncListener
This is a limited backport of commit #e0678b mainly providing the fix without
exposing the onError callbacks.

Issue: SPR-16058
2017-11-08 23:10:16 -05:00
Juergen Hoeller
ab19c227d3 DefaultResponseErrorHandler.hasError tolerates unknown status codes
Issue: SPR-16108
2017-10-24 15:44:37 +02:00
Juergen Hoeller
b0ae8f6058 ModelAttributeMethodProcessor detects re-enabled binding declaration
Issue: SPR-16083

(cherry picked from commit bec1fc1)
2017-10-18 13:29:41 +02:00
Juergen Hoeller
9fdc4404a5 Backport selected refinements from the nullability efforts
Issue: SPR-15656
2017-09-27 00:10:04 +02:00
Juergen Hoeller
87df393f91 MockPart backport
Issue: SPR-15854
2017-09-27 00:09:09 +02:00
Juergen Hoeller
53a9697ff1 Consistent conversion of Optional array/list arrangements
Issue: SPR-15918
Issue: SPR-15919
Issue: SPR-15676

(cherry picked from commit 15c82af)
2017-09-27 00:07:55 +02:00
Juergen Hoeller
17f42fc97a Polishing 2017-09-08 19:42:32 +02:00
Brian Bohl
f5d689e764 Fix StringIndexOutOfBoundsException in RestTemplate
Backport for commits #81dfad and #3d61f7

Issue: SPR-15900
2017-09-01 17:00:23 -04:00
Rossen Stoyanchev
681ced8fd3 Cancel WebAsyncManager thread on request timeout
Issue: SPR-15852
2017-08-16 09:42:39 +02:00
Rossen Stoyanchev
35248498ae Fix regression in HttpPutFormContentFilter
Re-arrange the checks so that if there is no form parameter, then
immediately and unconditionally delegate to super.getParameterValues().
Or reversely if there is no super.getParameterValues() then return the
form parameter.

So the only remaining case is when combining values present in both.
In that case we'll take both only if a queryString exists.

One extra fix is to not even wrap the request if we did not parse any
form parameters at all which can happen with HttpHiddenMethodFilter.

Issue: SPR-15828, 15835
2017-08-01 12:41:45 +02:00
Rossen Stoyanchev
cd602e5904 Deprecate setContentDispositionFormData method
The method was orginally added under SPR-14547 but the example in it
was probably intended for use with Content-Disposition server response
header (file download) and not for a Content-Disposition header
within the body of a multipart request.

In a Spring application a multipart request is typically serialized
by the FormHttpMessageConverter and hence the Content-Disposition is
not explicitly set by the application.
2017-07-20 17:58:52 +02:00
Juergen Hoeller
40b4276475 UriUtils.extractFileExtension properly handles all fragments
Issue: SPR-15786
(cherry picked from commit 13080f0)
2017-07-19 23:54:57 +02:00
Rossen Stoyanchev
4160ced64c Backport of relative redirect filter support
Issue: SPR-15717
2017-07-19 23:54:32 +02:00
Rossen Stoyanchev
8d743181da Fix MockMvc + HttpPutFormContentFilter issue
Issue: SPR-15753
2017-07-11 12:03:07 +02:00
Brian Clozel
d4d609318d Include port info in HTTP headers for Netty client
This commit adds the port information in the "Host" HTTP request header
for the Netty-based HTTP client.

Issue: SPR-15706
(cherry-picked from commit baaa84e90)
2017-07-04 12:19:54 +02:00
Juergen Hoeller
b35c238d27 Cleanup of duplicate semicolons
Issue: SPR-15654
(cherry picked from commit 779deb0)
2017-06-30 16:06:05 +02:00
Rossen Stoyanchev
04a96ffa27 Add removeOnly mode to ForwardedHeaderFilter
Issue: SPR-15610
2017-06-01 15:48:39 -04:00
Juergen Hoeller
81143a80c4 Wrap IOException as HttpMessageNotReadableException for RestTemplate usage
In the 4.3.x line, conversion exceptions do not get wrapped as RestClientException yet, so the expectation remains to receive a HttpMessageNotReadableException for conversion-level IOExceptions.

Issue: SPR-13592
2017-05-08 08:42:06 +02:00
Juergen Hoeller
9572859a35 Expect IOException instead of HttpMessageNotReadableException 2017-05-07 22:10:55 +02:00
Gregory Vandenbroucke
554c3f3d7e Full "Forwarded" header support including port number
Issue: SPR-15504
2017-05-02 17:00:48 -04:00
Juergen Hoeller
a9a1f783c5 Polishing 2017-04-13 15:59:15 +02:00
Rob Winch
95099fd709 Fix ForwardedHeaderFilter preserves semicolon content
Previously a requestURI that contained ';' would have the value incorrectly stripped out when using
ForwardedHeaderFilter.

This commit ensures that the ';' is preserved when using ForwardedHeaderFilter.

Issue: SPR-15428
2017-04-10 09:15:15 -05:00
Rob Winch
f65e1edd58 Polish
Group all contextPath tests together
2017-04-10 09:15:07 -05:00
Rob Winch
0a9f98f0df Add test to ensure ForwardedHeaderFilter contextPath preserves encoding
Add a test to verify that the ForwardedHeaderFilter contextPath override preserves URL encoding
as it should.

Issue SPR-15422
2017-04-10 09:13:41 -05:00
Rob Winch
46cf4f9ba1 ForwardedHeaderFilter requestURI preserve encoding
Previously ForwardedHeaderFilter would override the requestURI with a URL decoded value. This would cause
problems when using a URL encoded requestURI since downstream Filters would not see the URL encoded
value as they should.

This commit resolves this issue by ensuring that the requestURI is properly encoded.

Issues SPR-15422
2017-04-10 09:11:08 -05:00
Bryan Kelly
d0d7a88233 Fix ForwardedHeaderFilter getRequestURL()
Previously ForwardedHeaderFilter would return the same StringBuffer for every invocation. This
meant that users that modified the StringBuffer changed the state of the HttpServletRequest.

This commit ensures that a new StringBuffer is always returned for ForwardedHeaderFilter.

Issue: SPR-15423
2017-04-07 15:45:23 -05:00
Juergen Hoeller
21ac764e5c Polishing 2017-03-24 13:41:34 +01:00
Juergen Hoeller
22ddb35258 HeaderValueHolder.toString() exposes underlying list of header values
Issue: SPR-15375
(cherry picked from commit 15bff8f)
2017-03-24 13:40:43 +01:00