Issue #346 HttpParser RFC2616 Compliance mode

Ignore headers without values.
This commit is contained in:
Greg Wilkins 2016-03-05 11:03:11 +01:00
parent f4453ba5e0
commit 58e5a54ab6
4 changed files with 11 additions and 10 deletions

View File

@ -33,6 +33,7 @@ import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.Utf8StringBuilder; import org.eclipse.jetty.util.Utf8StringBuilder;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.omg.CosNaming._NamingContextExtStub;
import static org.eclipse.jetty.http.HttpTokens.CARRIAGE_RETURN; import static org.eclipse.jetty.http.HttpTokens.CARRIAGE_RETURN;
import static org.eclipse.jetty.http.HttpTokens.LINE_FEED; import static org.eclipse.jetty.http.HttpTokens.LINE_FEED;
@ -1174,8 +1175,12 @@ public class HttpParser
{ {
_value=null; _value=null;
_string.setLength(0); _string.setLength(0);
_valueString=_compliance.ordinal()<=HttpCompliance.RFC2616.ordinal()?"":null; _valueString=null;
_length=-1; _length=-1;
if (_compliance.ordinal()<=HttpCompliance.RFC2616.ordinal())
_valueString="";
else
_headerString=null;
setState(State.HEADER); setState(State.HEADER);
break; break;

View File

@ -388,13 +388,9 @@ public class HttpParserTest
assertEquals("HTTP/1.0", _versionOrReason); assertEquals("HTTP/1.0", _versionOrReason);
assertEquals("Host", _hdr[0]); assertEquals("Host", _hdr[0]);
assertEquals("localhost", _val[0]); assertEquals("localhost", _val[0]);
assertEquals("Name0", _hdr[1]); assertEquals("Connection", _hdr[1]);
assertEquals(null, _val[1]); assertEquals("close", _val[1]);
assertEquals("Name1", _hdr[2]); assertEquals(1, _headers);
assertEquals(null, _val[2]);
assertEquals("Connection", _hdr[3]);
assertEquals("close", _val[3]);
assertEquals(3, _headers);
} }
@Test @Test

View File

@ -236,7 +236,7 @@ public class PrefaceTest extends AbstractTest
"Host: localhost\r\n" + "Host: localhost\r\n" +
"Connection: Upgrade, HTTP2-Settings\r\n" + "Connection: Upgrade, HTTP2-Settings\r\n" +
"Upgrade: h2c\r\n" + "Upgrade: h2c\r\n" +
"HTTP2-Settings: \r\n" + "HTTP2-Settings: ==\r\n" +
"\r\n"; "\r\n";
ByteBuffer upgradeBuffer = ByteBuffer.wrap(upgradeRequest.getBytes(StandardCharsets.ISO_8859_1)); ByteBuffer upgradeBuffer = ByteBuffer.wrap(upgradeRequest.getBytes(StandardCharsets.ISO_8859_1));
socket.write(upgradeBuffer); socket.write(upgradeBuffer);

View File

@ -123,7 +123,7 @@ public class HTTP2CServerTest extends AbstractServerTest
"Host: localhost\r\n" + "Host: localhost\r\n" +
"Connection: something, else, upgrade, HTTP2-Settings\r\n" + "Connection: something, else, upgrade, HTTP2-Settings\r\n" +
"Upgrade: h2c\r\n" + "Upgrade: h2c\r\n" +
"HTTP2-Settings: \r\n" + "HTTP2-Settings: ==\r\n" +
"\r\n").getBytes(StandardCharsets.ISO_8859_1)); "\r\n").getBytes(StandardCharsets.ISO_8859_1));
output.flush(); output.flush();