Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
53853df3bb
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.http;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
@ -51,30 +52,56 @@ public class PreEncodedHttpField extends HttpField
|
|||
{
|
||||
try
|
||||
{
|
||||
encoders.add(iter.next());
|
||||
HttpFieldPreEncoder encoder = iter.next();
|
||||
if (index(encoder.getHttpVersion())>=0)
|
||||
encoders.add(encoder);
|
||||
}
|
||||
catch(Error|RuntimeException e)
|
||||
{
|
||||
LOG.debug(e);
|
||||
}
|
||||
}
|
||||
// TODO avoid needing this catch all
|
||||
if (encoders.size()==0)
|
||||
encoders.add(new Http1FieldPreEncoder());
|
||||
LOG.debug("HttpField encoders loaded: {}",encoders);
|
||||
__encoders = encoders.toArray(new HttpFieldPreEncoder[encoders.size()]);
|
||||
int size=encoders.size();
|
||||
|
||||
__encoders = new HttpFieldPreEncoder[size==0?1:size];
|
||||
for (HttpFieldPreEncoder e:encoders)
|
||||
{
|
||||
int i = index(e.getHttpVersion());
|
||||
if (__encoders[i]==null)
|
||||
__encoders[i] = e;
|
||||
else
|
||||
LOG.warn("multiple PreEncoders for "+e.getHttpVersion());
|
||||
}
|
||||
|
||||
// Always support HTTP1
|
||||
if (__encoders[0]==null)
|
||||
__encoders[0] = new Http1FieldPreEncoder();
|
||||
}
|
||||
|
||||
private final byte[][] _encodedField=new byte[2][];
|
||||
private static int index(HttpVersion version)
|
||||
{
|
||||
switch (version)
|
||||
{
|
||||
case HTTP_1_0:
|
||||
case HTTP_1_1:
|
||||
return 0;
|
||||
|
||||
case HTTP_2:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private final byte[][] _encodedField=new byte[__encoders.length][];
|
||||
|
||||
public PreEncodedHttpField(HttpHeader header,String name,String value)
|
||||
{
|
||||
super(header,name, value);
|
||||
|
||||
for (HttpFieldPreEncoder e:__encoders)
|
||||
{
|
||||
_encodedField[e.getHttpVersion()==HttpVersion.HTTP_2?1:0]=e.getEncodedField(header,header.asString(),value);
|
||||
}
|
||||
for (int i=0;i<__encoders.length;i++)
|
||||
_encodedField[i]=__encoders[i].getEncodedField(header,header.asString(),value);
|
||||
}
|
||||
|
||||
public PreEncodedHttpField(HttpHeader header,String value)
|
||||
|
@ -89,6 +116,6 @@ public class PreEncodedHttpField extends HttpField
|
|||
|
||||
public void putTo(ByteBuffer bufferInFillMode, HttpVersion version)
|
||||
{
|
||||
bufferInFillMode.put(_encodedField[version==HttpVersion.HTTP_2?1:0]);
|
||||
bufferInFillMode.put(_encodedField[index(version)]);
|
||||
}
|
||||
}
|
20
pom.xml
20
pom.xml
|
@ -1437,6 +1437,26 @@
|
|||
<alpn.version>8.1.9.v20160720</alpn.version>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jdk9</id>
|
||||
<activation>
|
||||
<jdk>1.9</jdk>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.9</source>
|
||||
<target>1.9</target>
|
||||
<testSource>1.9</testSource>
|
||||
<testTarget>1.9</testTarget>
|
||||
<compilerArgument>-Xlint:all</compilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<issueManagement>
|
||||
|
|
Loading…
Reference in New Issue