327109 (re)fixed AJP handling of empty packets

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2589 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-12-05 15:19:06 +00:00
parent de36611978
commit ba0e1d3935
6 changed files with 53 additions and 71 deletions

View File

@ -1,3 +1,5 @@
+ 327109 (re)fixed AJP handling of empty packets
jetty-7.2.2.v20101203 3 December 2010
+ 331703 Fixed failing OSGI test TestJettyOSGiBootWithJsp.java on MacOSX
+ 331567 IPAccessHandlerTest failed on MacOS fix

View File

@ -38,6 +38,11 @@
<artifactId>jetty-jmx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-ajp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-websocket</artifactId>

View File

@ -15,6 +15,7 @@ package org.eclipse.jetty.embedded;
import java.lang.management.ManagementFactory;
import org.eclipse.jetty.ajp.Ajp13SocketConnector;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.deploy.providers.ContextProvider;
import org.eclipse.jetty.deploy.providers.WebAppProvider;
@ -85,6 +86,10 @@ public class LikeJettyXml
});
server.addConnector(ssl_connector);
Ajp13SocketConnector ajp = new Ajp13SocketConnector();
ajp.setPort(8009);
server.addConnector(ajp);
HandlerCollection handlers = new HandlerCollection();
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLogHandler requestLogHandler = new RequestLogHandler();

View File

@ -72,11 +72,8 @@ public class Ajp13Connection extends HttpConnection
private class RequestHandler implements Ajp13Parser.EventHandler
{
boolean _delayedHandling = false;
public void startForwardRequest() throws IOException
{
_delayedHandling = false;
_uri.clear();
((Ajp13Request) _request).setSslSecure(false);
@ -225,14 +222,7 @@ public class Ajp13Connection extends HttpConnection
public void headerComplete() throws IOException
{
if (((Ajp13Parser) _parser).getContentLength() <= 0)
{
handleRequest();
}
else
{
_delayedHandling = true;
}
handleRequest();
}
public void messageComplete(long contextLength) throws IOException
@ -241,11 +231,6 @@ public class Ajp13Connection extends HttpConnection
public void content(Buffer ref) throws IOException
{
if (_delayedHandling)
{
_delayedHandling = false;
handleRequest();
}
}
}

View File

@ -36,8 +36,7 @@ public class Ajp13Parser implements Parser
private final static int STATE_START = -1;
private final static int STATE_END = 0;
private final static int STATE_AJP13CHUNK_START = 1;
private final static int STATE_AJP13CHUNK_START_AFTER_LENGTH = 2;
private final static int STATE_AJP13CHUNK = 3;
private final static int STATE_AJP13CHUNK = 2;
private int _state = STATE_START;
private long _contentLength;
@ -227,6 +226,7 @@ public class Ajp13Parser implements Parser
return filled;
}
volatile int _seq=0;
/* ------------------------------------------------------------------------------- */
public long parseNext() throws IOException
{
@ -294,7 +294,7 @@ public class Ajp13Parser implements Parser
int attr_type = 0;
byte packetType = Ajp13RequestPacket.getByte(_buffer);
switch (packetType)
{
case Ajp13Packet.FORWARD_REQUEST_ORDINAL:
@ -365,7 +365,6 @@ public class Ajp13Parser implements Parser
attr_type = Ajp13RequestPacket.getByte(_buffer) & 0xff;
while (attr_type != 0xFF)
{
switch (attr_type)
{
// XXX How does this plug into the web
@ -469,11 +468,6 @@ public class Ajp13Parser implements Parser
attr_type = Ajp13RequestPacket.getByte(_buffer) & 0xff;
}
_contentPosition = 0;
switch ((int) _contentLength)
{
@ -512,7 +506,6 @@ public class Ajp13Parser implements Parser
}
}
Buffer chunk;
while (_state>STATE_END)
@ -520,12 +513,12 @@ public class Ajp13Parser implements Parser
switch (_state)
{
case STATE_AJP13CHUNK_START:
if (_buffer.length()<4)
if (_buffer.length()<6)
{
if (total_filled<0)
total_filled=0;
total_filled+=fill();
if (_buffer.length()<4)
if (_buffer.length()<6)
return total_filled;
}
int _magic=Ajp13RequestPacket.getInt(_buffer);
@ -535,28 +528,17 @@ public class Ajp13Parser implements Parser
+Integer.toHexString(Ajp13RequestHeaders.MAGIC)+" "+this);
}
_chunkPosition=0;
int rawChunkLength=Ajp13RequestPacket.getInt(_buffer);
_chunkLength = rawChunkLength - 2;
if (rawChunkLength==0 || _chunkLength==0)
_chunkLength=Ajp13RequestPacket.getInt(_buffer)-2;
Ajp13RequestPacket.getInt(_buffer);
if (_chunkLength==0)
{
_state=STATE_END;
_generator.gotBody();
_handler.messageComplete(_contentPosition);
return total_filled;
}
_state=STATE_AJP13CHUNK_START_AFTER_LENGTH;
case STATE_AJP13CHUNK_START_AFTER_LENGTH:
if (_buffer.length() < 2)
{
if (total_filled < 0)
total_filled = 0;
total_filled += fill();
if (_buffer.length() < 2)
return total_filled;
}
Ajp13RequestPacket.getInt(_buffer);
_state = STATE_AJP13CHUNK;
_state=STATE_AJP13CHUNK;
break;
case STATE_AJP13CHUNK:
if (_buffer.length()<_chunkLength)
@ -569,7 +551,7 @@ public class Ajp13Parser implements Parser
}
int remaining=_chunkLength-_chunkPosition;
if (remaining==0)
{
_state=STATE_AJP13CHUNK_START;
@ -591,6 +573,7 @@ public class Ajp13Parser implements Parser
}
chunk=Ajp13RequestPacket.get(_buffer,remaining);
_contentPosition+=chunk.length();
_chunkPosition+=chunk.length();
_contentView.update(chunk);
@ -620,7 +603,7 @@ public class Ajp13Parser implements Parser
}
}
return total_filled;
}
@ -836,7 +819,7 @@ public class Ajp13Parser implements Parser
{
if (_content.length() > 0)
return true;
if (_parser.isState(Ajp13Parser.STATE_END))
if (_parser.isState(Ajp13Parser.STATE_END) || _parser.isState(Ajp13Parser.STATE_START))
return false;
// Handle simple end points.

View File

@ -475,127 +475,129 @@ public class TestAjpParser
private static class EH implements Ajp13Parser.EventHandler
{
final boolean debug=false;
public void content(Buffer ref) throws IOException
{
// System.err.println(ref);
if (debug) System.err.println(ref);
}
public void headerComplete() throws IOException
{
// System.err.println("--");
if (debug) System.err.println("--");
}
public void messageComplete(long contextLength) throws IOException
{
// System.err.println("==");
if (debug) System.err.println("==");
}
public void parsedHeader(Buffer name, Buffer value) throws IOException
{
// System.err.println(name+": "+value);
if (debug) System.err.println(name+": "+value);
}
public void parsedMethod(Buffer method) throws IOException
{
// System.err.println(method);
if (debug) System.err.println(method);
}
public void parsedProtocol(Buffer protocol) throws IOException
{
// System.err.println(protocol);
if (debug) System.err.println(protocol);
}
public void parsedQueryString(Buffer value) throws IOException
{
// System.err.println("?"+value);
if (debug) System.err.println("?"+value);
}
public void parsedRemoteAddr(Buffer addr) throws IOException
{
// System.err.println("addr="+addr);
if (debug) System.err.println("addr="+addr);
}
public void parsedRemoteHost(Buffer host) throws IOException
{
// System.err.println("host="+host);
if (debug) System.err.println("host="+host);
}
public void parsedRequestAttribute(String key, Buffer value) throws IOException
{
// System.err.println(key+":: "+value);
if (debug) System.err.println(key+":: "+value);
}
public void parsedServerName(Buffer name) throws IOException
{
// System.err.println("Server:: "+name);
if (debug) System.err.println("Server:: "+name);
}
public void parsedServerPort(int port) throws IOException
{
// System.err.println("Port:: "+port);
if (debug) System.err.println("Port:: "+port);
}
public void parsedSslSecure(boolean secure) throws IOException
{
// System.err.println("Secure:: "+secure);
if (debug) System.err.println("Secure:: "+secure);
}
public void parsedUri(Buffer uri) throws IOException
{
// System.err.println(uri);
if (debug) System.err.println("URI:: "+uri);
}
public void startForwardRequest() throws IOException
{
// System.err.println("..");
if (debug) System.err.println("..");
}
public void parsedAuthorizationType(Buffer authType) throws IOException
{
//To change body of implemented methods use File | Settings | File Templates.
if (debug) System.err.println("auth:: "+authType);
}
public void parsedRemoteUser(Buffer remoteUser) throws IOException
{
//To change body of implemented methods use File | Settings | File Templates.
if (debug) System.err.println("user:: "+remoteUser);
}
public void parsedServletPath(Buffer servletPath) throws IOException
{
//To change body of implemented methods use File | Settings | File Templates.
if (debug) System.err.println("servletPath:: "+servletPath);
}
public void parsedContextPath(Buffer context) throws IOException
{
//To change body of implemented methods use File | Settings | File Templates.
if (debug) System.err.println("Context:: "+context);
}
public void parsedSslCert(Buffer sslCert) throws IOException
{
//To change body of implemented methods use File | Settings | File Templates.
if (debug) System.err.println("sslCert:: "+sslCert);
}
public void parsedSslCipher(Buffer sslCipher) throws IOException
{
//To change body of implemented methods use File | Settings | File Templates.
if (debug) System.err.println("sslCipher:: "+sslCipher);
}
public void parsedSslSession(Buffer sslSession) throws IOException
{
//To change body of implemented methods use File | Settings | File Templates.
if (debug) System.err.println("sslSession:: "+sslSession);
}
public void parsedSslKeySize(int keySize) throws IOException
{
// System.err.println(key+":: "+value);
if (debug) System.err.println("sslkeysize:: "+keySize);
}
public void parsedRequestAttribute(String key, int value) throws IOException
{
// System.err.println(key+":: "+value);
if (debug) System.err.println(key+":: "+value);
}
}
}