Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-07-18 11:08:05 +02:00
parent 7037e86d3b
commit 42844f2c5f
2 changed files with 16 additions and 15 deletions

View File

@ -236,21 +236,23 @@ 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;

View File

@ -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"));
}
}