parent
7037e86d3b
commit
42844f2c5f
|
@ -236,27 +236,29 @@ public class MetaDataBuilder
|
|||
if (_request && _response)
|
||||
throw new HpackException.StreamException("Request and Response headers");
|
||||
|
||||
|
||||
HttpFields fields = _fields;
|
||||
try
|
||||
{
|
||||
HttpFields fields = _fields;
|
||||
_fields = new HttpFields(Math.max(10,fields.size()+5));
|
||||
|
||||
if (_method!=null || _path!=null || _authority!=null || _scheme!=null)
|
||||
if (_request)
|
||||
return new MetaData.Request(_method,_scheme,_authority,_path,HttpVersion.HTTP_2,fields,_contentLength);
|
||||
if (_status>0)
|
||||
if (_response)
|
||||
return new MetaData.Response(HttpVersion.HTTP_2,_status,fields,_contentLength);
|
||||
|
||||
return new MetaData(HttpVersion.HTTP_2,fields,_contentLength);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_status=0;
|
||||
_fields = new HttpFields(Math.max(10,fields.size()+5));
|
||||
_request=false;
|
||||
_response=false;
|
||||
_status=-1;
|
||||
_method=null;
|
||||
_scheme=null;
|
||||
_authority=null;
|
||||
_path=null;
|
||||
_size=0;
|
||||
_contentLength=Long.MIN_VALUE;
|
||||
_contentLength=Long.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,18 @@
|
|||
|
||||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.DateGenerator;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http.MetaData.Response;
|
||||
|
@ -35,10 +38,6 @@ import org.eclipse.jetty.util.BufferUtil;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class HpackTest
|
||||
{
|
||||
final static HttpField ServerJetty = new PreEncodedHttpField(HttpHeader.SERVER,"jetty");
|
||||
|
@ -131,9 +130,9 @@ public class HpackTest
|
|||
decoder.decode(buffer);
|
||||
Assert.fail();
|
||||
}
|
||||
catch(BadMessageException e)
|
||||
catch(HpackException.SessionException e)
|
||||
{
|
||||
assertEquals(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431,e.getCode());
|
||||
assertThat(e.getMessage(),containsString("Header too large"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue