Merge branch 'jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
b4a0d7ebcb
|
@ -452,23 +452,21 @@ public class Request implements HttpServletRequest
|
|||
/* ------------------------------------------------------------ */
|
||||
private void extractContentParameters()
|
||||
{
|
||||
// Content cannot be encoded
|
||||
if (_metaData!=null && getHttpFields().contains(HttpHeader.CONTENT_ENCODING))
|
||||
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501,"Unsupported Content-Encoding");
|
||||
|
||||
String contentType = getContentType();
|
||||
if (contentType == null || contentType.isEmpty())
|
||||
_contentParameters=NO_PARAMS;
|
||||
else
|
||||
{
|
||||
_contentParameters=new MultiMap<>();
|
||||
contentType = HttpFields.valueParameters(contentType, null);
|
||||
int contentLength = getContentLength();
|
||||
if (contentLength != 0 && _inputState == __NONE)
|
||||
{
|
||||
contentType = HttpFields.valueParameters(contentType, null);
|
||||
if (MimeTypes.Type.FORM_ENCODED.is(contentType) &&
|
||||
_channel.getHttpConfiguration().isFormEncodedMethod(getMethod()))
|
||||
{
|
||||
if (_metaData!=null && getHttpFields().contains(HttpHeader.CONTENT_ENCODING))
|
||||
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501,"Unsupported Content-Encoding");
|
||||
extractFormParameters(_contentParameters);
|
||||
}
|
||||
else if (MimeTypes.Type.MULTIPART_FORM_DATA.is(contentType) &&
|
||||
|
@ -477,6 +475,8 @@ public class Request implements HttpServletRequest
|
|||
{
|
||||
try
|
||||
{
|
||||
if (_metaData!=null && getHttpFields().contains(HttpHeader.CONTENT_ENCODING))
|
||||
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501,"Unsupported Content-Encoding");
|
||||
getParts(_contentParameters);
|
||||
}
|
||||
catch (IOException | ServletException e)
|
||||
|
@ -487,7 +487,6 @@ public class Request implements HttpServletRequest
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
@ -28,7 +29,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
@ -635,7 +635,7 @@ public class RequestTest
|
|||
};
|
||||
|
||||
//Send a request with encoded form content
|
||||
String request="GET / HTTP/1.1\r\n"+
|
||||
String request="POST / HTTP/1.1\r\n"+
|
||||
"Host: whatever\r\n"+
|
||||
"Content-Type: application/x-www-form-urlencoded; charset=utf-8\n"+
|
||||
"Content-Length: 10\n"+
|
||||
|
@ -648,6 +648,34 @@ public class RequestTest
|
|||
assertThat(responses,startsWith("HTTP/1.1 200"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodedNotParams() throws Exception
|
||||
{
|
||||
_handler._checker = new RequestTester()
|
||||
{
|
||||
@Override
|
||||
public boolean check(HttpServletRequest request,HttpServletResponse response)
|
||||
{
|
||||
return request.getParameter("param")==null;
|
||||
}
|
||||
};
|
||||
|
||||
//Send a request with encoded form content
|
||||
String request="POST / HTTP/1.1\r\n"+
|
||||
"Host: whatever\r\n"+
|
||||
"Content-Type: application/octet-stream\n"+
|
||||
"Content-Length: 10\n"+
|
||||
"Content-Encoding: gzip\n"+
|
||||
"Connection: close\n"+
|
||||
"\n"+
|
||||
"0123456789\n";
|
||||
|
||||
String responses=_connector.getResponse(request);
|
||||
assertThat(responses,startsWith("HTTP/1.1 200"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInvalidHostHeader() throws Exception
|
||||
{
|
||||
|
@ -1816,7 +1844,7 @@ public class RequestTest
|
|||
((Request)request).setHandled(true);
|
||||
|
||||
if (request.getContentLength()>0
|
||||
&& !MimeTypes.Type.FORM_ENCODED.asString().equals(request.getContentType())
|
||||
&& !request.getContentType().startsWith(MimeTypes.Type.FORM_ENCODED.asString())
|
||||
&& !request.getContentType().startsWith("multipart/form-data"))
|
||||
_content=IO.toString(request.getInputStream());
|
||||
|
||||
|
|
Loading…
Reference in New Issue