380212 Clear buffer if parsing fails due to full buffer
This commit is contained in:
parent
473ebb447a
commit
077b220cf8
|
@ -1020,7 +1020,8 @@ public class HttpParser implements Parser
|
|||
// Are we full?
|
||||
if (_buffer.space() == 0)
|
||||
{
|
||||
LOG.warn("Full {}",_buffer.toDetailString());
|
||||
LOG.warn("HttpParser Full for {} ",_endp);
|
||||
_buffer.clear();
|
||||
throw new HttpException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413, "FULL "+(_buffer==_body?"body":"head"));
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,36 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Feed a full header method
|
||||
*/
|
||||
@Test
|
||||
public void testFull() throws Exception
|
||||
{
|
||||
configureServer(new HelloWorldHandler());
|
||||
|
||||
Socket client=newSocket(HOST,_connector.getLocalPort());
|
||||
try
|
||||
{
|
||||
OutputStream os=client.getOutputStream();
|
||||
|
||||
byte[] buffer = new byte[64*1024];
|
||||
Arrays.fill(buffer,(byte)'A');
|
||||
|
||||
os.write(buffer);
|
||||
os.flush();
|
||||
|
||||
// Read the response.
|
||||
String response=readResponse(client);
|
||||
|
||||
Assert.assertTrue(response.contains("HTTP/1.1 413 FULL head"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.jetty.server.ssl;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
@ -82,4 +83,17 @@ public class SslSocketServerTest extends HttpServerTestBase
|
|||
public void testAvailable() throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testFull() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
super.testFull();
|
||||
}
|
||||
catch(SocketException e)
|
||||
{
|
||||
// For SSL Sockets, the response is closed before the 400 is sent???
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue