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()
|
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();
|
String contentType = getContentType();
|
||||||
if (contentType == null || contentType.isEmpty())
|
if (contentType == null || contentType.isEmpty())
|
||||||
_contentParameters=NO_PARAMS;
|
_contentParameters=NO_PARAMS;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_contentParameters=new MultiMap<>();
|
_contentParameters=new MultiMap<>();
|
||||||
contentType = HttpFields.valueParameters(contentType, null);
|
|
||||||
int contentLength = getContentLength();
|
int contentLength = getContentLength();
|
||||||
if (contentLength != 0 && _inputState == __NONE)
|
if (contentLength != 0 && _inputState == __NONE)
|
||||||
{
|
{
|
||||||
|
contentType = HttpFields.valueParameters(contentType, null);
|
||||||
if (MimeTypes.Type.FORM_ENCODED.is(contentType) &&
|
if (MimeTypes.Type.FORM_ENCODED.is(contentType) &&
|
||||||
_channel.getHttpConfiguration().isFormEncodedMethod(getMethod()))
|
_channel.getHttpConfiguration().isFormEncodedMethod(getMethod()))
|
||||||
{
|
{
|
||||||
|
if (_metaData!=null && getHttpFields().contains(HttpHeader.CONTENT_ENCODING))
|
||||||
|
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501,"Unsupported Content-Encoding");
|
||||||
extractFormParameters(_contentParameters);
|
extractFormParameters(_contentParameters);
|
||||||
}
|
}
|
||||||
else if (MimeTypes.Type.MULTIPART_FORM_DATA.is(contentType) &&
|
else if (MimeTypes.Type.MULTIPART_FORM_DATA.is(contentType) &&
|
||||||
|
@ -477,6 +475,8 @@ public class Request implements HttpServletRequest
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (_metaData!=null && getHttpFields().contains(HttpHeader.CONTENT_ENCODING))
|
||||||
|
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501,"Unsupported Content-Encoding");
|
||||||
getParts(_contentParameters);
|
getParts(_contentParameters);
|
||||||
}
|
}
|
||||||
catch (IOException | ServletException e)
|
catch (IOException | ServletException e)
|
||||||
|
@ -487,7 +487,6 @@ public class Request implements HttpServletRequest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.server;
|
package org.eclipse.jetty.server;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.not;
|
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.assertNotSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
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.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
@ -635,7 +635,7 @@ public class RequestTest
|
||||||
};
|
};
|
||||||
|
|
||||||
//Send a request with encoded form content
|
//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"+
|
"Host: whatever\r\n"+
|
||||||
"Content-Type: application/x-www-form-urlencoded; charset=utf-8\n"+
|
"Content-Type: application/x-www-form-urlencoded; charset=utf-8\n"+
|
||||||
"Content-Length: 10\n"+
|
"Content-Length: 10\n"+
|
||||||
|
@ -648,6 +648,34 @@ public class RequestTest
|
||||||
assertThat(responses,startsWith("HTTP/1.1 200"));
|
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
|
@Test
|
||||||
public void testInvalidHostHeader() throws Exception
|
public void testInvalidHostHeader() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -1816,7 +1844,7 @@ public class RequestTest
|
||||||
((Request)request).setHandled(true);
|
((Request)request).setHandled(true);
|
||||||
|
|
||||||
if (request.getContentLength()>0
|
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"))
|
&& !request.getContentType().startsWith("multipart/form-data"))
|
||||||
_content=IO.toString(request.getInputStream());
|
_content=IO.toString(request.getInputStream());
|
||||||
|
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -522,7 +522,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-pmd-plugin</artifactId>
|
<artifactId>maven-pmd-plugin</artifactId>
|
||||||
<version>3.11.0-SNAPSHOT</version>
|
<version>3.11.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
Loading…
Reference in New Issue