SPR-8676 Fix minor issue in how ServletServletHttpRequest detects form content-type requests
This commit is contained in:
parent
de504fa613
commit
28a696ba51
|
|
@ -30,6 +30,7 @@ import java.util.Enumeration;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
@ -115,7 +116,7 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
|||
}
|
||||
|
||||
private boolean isFormSubmittal(HttpServletRequest request) {
|
||||
return FORM_CONTENT_TYPE.equals(request.getContentType()) &&
|
||||
return request.getContentType() != null && request.getContentType().contains(FORM_CONTENT_TYPE) &&
|
||||
(METHOD_POST.equalsIgnoreCase(request.getMethod()) || METHOD_PUT.equalsIgnoreCase(request.getMethod()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import static org.junit.Assert.*;
|
|||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class ServletHttpRequestTests {
|
||||
public class ServletServerHttpRequestTests {
|
||||
|
||||
private ServletServerHttpRequest request;
|
||||
|
||||
|
|
@ -88,7 +88,8 @@ public class ServletHttpRequestTests {
|
|||
|
||||
@Test
|
||||
public void getFormBody() throws Exception {
|
||||
mockRequest.setContentType("application/x-www-form-urlencoded");
|
||||
// Charset (SPR-8676)
|
||||
mockRequest.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
|
||||
mockRequest.setMethod("POST");
|
||||
mockRequest.addParameter("name 1", "value 1");
|
||||
mockRequest.addParameter("name 2", new String[] {"value 2+1", "value 2+2"});
|
||||
|
|
@ -98,4 +99,5 @@ public class ServletHttpRequestTests {
|
|||
byte[] content = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3".getBytes("UTF-8");
|
||||
assertArrayEquals("Invalid content returned", content, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ import org.springframework.http.HttpStatus;
|
|||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class ServletHttpResponseTests {
|
||||
public class ServletServerHttpResponseTests {
|
||||
|
||||
private ServletServerHttpResponse response;
|
||||
|
||||
Loading…
Reference in New Issue