improve value handling on known literal fields
This commit is contained in:
parent
f2e8edca9c
commit
073ad924b0
|
@ -554,23 +554,4 @@ public class HpackContext
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
public static class StaticValueHttpField extends HttpField
|
||||
{
|
||||
private final Object _value;
|
||||
|
||||
public StaticValueHttpField(String name, String valueString, Object value)
|
||||
{
|
||||
super(name,valueString);
|
||||
_value=value;
|
||||
}
|
||||
|
||||
public Object getStaticValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http2.hpack.HpackContext.Entry;
|
||||
|
||||
|
||||
|
@ -119,11 +121,37 @@ public class HpackDecoder
|
|||
|
||||
// Make the new field
|
||||
HttpField field;
|
||||
if (":authority".equals(header))
|
||||
field = new AuthorityHttpField(value);
|
||||
else
|
||||
// Normal Field
|
||||
field = new HttpField(header,name,value);
|
||||
switch(name)
|
||||
{
|
||||
case ":method":
|
||||
HttpMethod method=HttpMethod.CACHE.get(value);
|
||||
if (method!=null)
|
||||
field = new StaticValueHttpField(header,name,method.asString(),method);
|
||||
else
|
||||
field = new AuthorityHttpField(value);
|
||||
break;
|
||||
|
||||
case ":status":
|
||||
Integer code = Integer.getInteger(value);
|
||||
field = new StaticValueHttpField(header,name,value,code);
|
||||
break;
|
||||
|
||||
case ":scheme":
|
||||
HttpScheme scheme=HttpScheme.CACHE.get(value);
|
||||
if (scheme!=null)
|
||||
field = new StaticValueHttpField(header,name,scheme.asString(),scheme);
|
||||
else
|
||||
field = new AuthorityHttpField(value);
|
||||
break;
|
||||
|
||||
case ":authority":
|
||||
field = new AuthorityHttpField(value);
|
||||
break;
|
||||
|
||||
default:
|
||||
field = new HttpField(header,name,value);
|
||||
break;
|
||||
}
|
||||
|
||||
// emit the field
|
||||
_builder.emit(field);
|
||||
|
|
|
@ -43,9 +43,9 @@ public class MetaDataBuilder
|
|||
|
||||
public void emit(HttpField field)
|
||||
{
|
||||
if (field instanceof HpackContext.StaticValueHttpField)
|
||||
if (field instanceof StaticValueHttpField)
|
||||
{
|
||||
HpackContext.StaticValueHttpField value = (HpackContext.StaticValueHttpField)field;
|
||||
StaticValueHttpField value = (StaticValueHttpField)field;
|
||||
switch(field.getName())
|
||||
{
|
||||
case ":status":
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
|
||||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public class StaticValueHttpField extends HttpField
|
||||
{
|
||||
private final Object _value;
|
||||
|
||||
public StaticValueHttpField(HttpHeader header,String name, String valueString, Object value)
|
||||
{
|
||||
super(header,name,valueString);
|
||||
_value=value;
|
||||
}
|
||||
|
||||
public StaticValueHttpField(String name, String valueString, Object value)
|
||||
{
|
||||
super(name,valueString);
|
||||
_value=value;
|
||||
}
|
||||
|
||||
public Object getStaticValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue