mirror of
https://github.com/jetty/jetty.project.git
synced 2025-02-25 17:18:30 +00:00
refactored to avoid copying MetaData.Request instances
This commit is contained in:
parent
fff2dd2f2d
commit
f9ffefbe13
@ -23,6 +23,7 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.eclipse.jetty.fcgi.FCGI;
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@ -87,7 +88,7 @@ public class HttpChannelOverFCGI extends HttpChannel
|
||||
String uri = path;
|
||||
if (query != null && query.length() > 0)
|
||||
uri += "?" + query;
|
||||
onRequest(new MetaData.Request(HttpVersion.fromString(version), method, new HttpURI(uri), fields, hostPort));
|
||||
onRequest(new FinalMetaData.Request(HttpVersion.fromString(version), method, new HttpURI(uri), fields, hostPort));
|
||||
}
|
||||
|
||||
private HttpField convertHeader(HttpField field)
|
||||
|
@ -0,0 +1,163 @@
|
||||
//
|
||||
// ========================================================================
|
||||
// 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.http;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public abstract class AbstractMetaData implements MetaData
|
||||
{
|
||||
@Override
|
||||
public boolean isRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<HttpField> iterator()
|
||||
{
|
||||
return getFields().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return 31 * getHttpVersion().hashCode() + getFields().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof AbstractMetaData))
|
||||
return false;
|
||||
AbstractMetaData that = (AbstractMetaData)o;
|
||||
|
||||
if (getHttpVersion() != that.getHttpVersion())
|
||||
return false;
|
||||
|
||||
return getFields().equals(that.getFields());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (HttpField field: this)
|
||||
out.append(field).append(System.lineSeparator());
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public abstract static class Request extends AbstractMetaData implements MetaData.Request
|
||||
{
|
||||
@Override
|
||||
public boolean isRequest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = getMethod().hashCode();
|
||||
hash = 31 * hash + getScheme().hashCode();
|
||||
hash = 31 * hash + getURI().hashCode();
|
||||
return 31 * hash + super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof MetaData.Request))
|
||||
return false;
|
||||
MetaData.Request that = (MetaData.Request)o;
|
||||
if (!getMethod().equals(that.getMethod()) ||
|
||||
!getScheme().equals(that.getScheme()) ||
|
||||
!getURI().equals(that.getURI()))
|
||||
return false;
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s %s://%s:%d%s HTTP/2%s%s",
|
||||
getMethod(), getScheme(), getHost(), getPort(), getURI(), System.lineSeparator(), super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public abstract static class Response extends AbstractMetaData implements MetaData.Response
|
||||
{
|
||||
@Override
|
||||
public boolean isRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return 31 * getStatus() + super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof MetaData.Response))
|
||||
return false;
|
||||
MetaData.Response that = (MetaData.Response)o;
|
||||
if (getStatus() != that.getStatus())
|
||||
return false;
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("HTTP/2 %d%s%s", getStatus(), System.lineSeparator(), super.toString());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
//
|
||||
// ========================================================================
|
||||
// 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.http;
|
||||
|
||||
|
||||
public class FinalMetaData extends AbstractMetaData
|
||||
{
|
||||
private final HttpVersion _version;
|
||||
private final HttpFields _fields;
|
||||
|
||||
public FinalMetaData(HttpVersion version,HttpFields fields)
|
||||
{
|
||||
_fields=fields;
|
||||
_version=version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpFields getFields()
|
||||
{
|
||||
return _fields;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public static class Request extends AbstractMetaData.Request
|
||||
{
|
||||
private final HttpVersion _version;
|
||||
private final HttpFields _fields;
|
||||
private final String _method;
|
||||
private final HttpURI _uri;
|
||||
private final HostPortHttpField _hostPort;
|
||||
private final HttpScheme _scheme;
|
||||
|
||||
public Request(HttpVersion version, String method, HttpURI uri, HttpFields fields, HostPortHttpField hostPort)
|
||||
{
|
||||
_fields=fields;
|
||||
_version=version;
|
||||
_method=method;
|
||||
_uri=uri;
|
||||
_hostPort = hostPort;
|
||||
String scheme = uri.getScheme();
|
||||
if (scheme == null)
|
||||
{
|
||||
_scheme = HttpScheme.HTTP;
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpScheme s = HttpScheme.CACHE.get(scheme);
|
||||
_scheme = s == null ? HttpScheme.HTTP : s;
|
||||
}
|
||||
}
|
||||
|
||||
public Request(HttpVersion version, HttpScheme scheme, String method, HostPortHttpField authority, String path, HttpFields fields)
|
||||
{
|
||||
this(version,scheme,method,authority,new HttpURI(path),fields);
|
||||
}
|
||||
|
||||
public Request(HttpVersion version, HttpScheme scheme, String method, HostPortHttpField authority, HttpURI path, HttpFields fields)
|
||||
{
|
||||
_fields=fields;
|
||||
_version=version;
|
||||
_method=method;
|
||||
_uri=path;
|
||||
_hostPort = authority;
|
||||
_scheme=scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpFields getFields()
|
||||
{
|
||||
return _fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod()
|
||||
{
|
||||
return _method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpScheme getScheme()
|
||||
{
|
||||
return _scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost()
|
||||
{
|
||||
return _hostPort==null?null:_hostPort.getHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort()
|
||||
{
|
||||
return _hostPort==null?0:_hostPort.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpURI getURI()
|
||||
{
|
||||
return _uri;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public static class Response extends AbstractMetaData.Response
|
||||
{
|
||||
private final HttpVersion _version;
|
||||
private final HttpFields _fields;
|
||||
private final int _status;
|
||||
|
||||
public Response(HttpVersion version, int status, HttpFields fields)
|
||||
{
|
||||
_fields=fields;
|
||||
_version=version;
|
||||
_status=status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpFields getFields()
|
||||
{
|
||||
return _fields;
|
||||
}
|
||||
|
||||
public int getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,239 +18,30 @@
|
||||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class MetaData implements Iterable<HttpField>
|
||||
public interface MetaData extends Iterable<HttpField>
|
||||
{
|
||||
private final HttpVersion _version;
|
||||
private final HttpFields _fields;
|
||||
|
||||
public MetaData(HttpVersion version,HttpFields fields)
|
||||
{
|
||||
_fields=fields;
|
||||
_version=version;
|
||||
}
|
||||
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
public boolean isRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isResponse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<HttpField> iterator()
|
||||
{
|
||||
return _fields.iterator();
|
||||
}
|
||||
|
||||
public HttpFields getFields()
|
||||
{
|
||||
return _fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return 31 * _version.hashCode() + _fields.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof MetaData))
|
||||
return false;
|
||||
MetaData that = (MetaData)o;
|
||||
|
||||
if (_version != that._version)
|
||||
return false;
|
||||
|
||||
return _fields.equals(that._fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (HttpField field: this)
|
||||
out.append(field).append(System.lineSeparator());
|
||||
return out.toString();
|
||||
}
|
||||
public HttpVersion getHttpVersion();
|
||||
public boolean isRequest();
|
||||
public boolean isResponse();
|
||||
public HttpFields getFields();
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public static class Request extends MetaData
|
||||
public interface Request extends MetaData
|
||||
{
|
||||
private final String _method;
|
||||
private final HttpURI _uri;
|
||||
private final HostPortHttpField _hostPort;
|
||||
private final HttpScheme _scheme;
|
||||
|
||||
public Request(HttpVersion version, String method, HttpURI uri, HttpFields fields, HostPortHttpField hostPort)
|
||||
{
|
||||
super(version,fields);
|
||||
_method=method;
|
||||
_uri=uri;
|
||||
_hostPort = hostPort;
|
||||
String scheme = uri.getScheme();
|
||||
if (scheme == null)
|
||||
{
|
||||
_scheme = HttpScheme.HTTP;
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpScheme s = HttpScheme.CACHE.get(scheme);
|
||||
_scheme = s == null ? HttpScheme.HTTP : s;
|
||||
}
|
||||
}
|
||||
|
||||
public Request(HttpVersion version, HttpScheme scheme, String method, HostPortHttpField authority, String path, HttpFields fields)
|
||||
{
|
||||
this(version,scheme,method,authority,new HttpURI(path),fields);
|
||||
}
|
||||
|
||||
public Request(HttpVersion version, HttpScheme scheme, String method, HostPortHttpField authority, HttpURI path, HttpFields fields)
|
||||
{
|
||||
super(version,fields);
|
||||
_method=method;
|
||||
_uri=path;
|
||||
_hostPort = authority;
|
||||
_scheme=scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getMethod()
|
||||
{
|
||||
return _method;
|
||||
}
|
||||
|
||||
public HttpScheme getScheme()
|
||||
{
|
||||
return _scheme;
|
||||
}
|
||||
|
||||
public String getHost()
|
||||
{
|
||||
return _hostPort==null?null:_hostPort.getHost();
|
||||
}
|
||||
|
||||
public int getPort()
|
||||
{
|
||||
return _hostPort==null?0:_hostPort.getPort();
|
||||
}
|
||||
|
||||
public HttpURI getURI()
|
||||
{
|
||||
return _uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = _method.hashCode();
|
||||
hash = 31 * hash + _scheme.hashCode();
|
||||
hash = 31 * hash + _uri.hashCode();
|
||||
return 31 * hash + super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Request))
|
||||
return false;
|
||||
Request that = (Request)o;
|
||||
if (!_method.equals(that._method) ||
|
||||
!_scheme.equals(that._scheme) ||
|
||||
!_uri.equals(that._uri))
|
||||
return false;
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s %s://%s:%d%s HTTP/2%s%s",
|
||||
getMethod(), getScheme(), getHost(), getPort(), getURI(), System.lineSeparator(), super.toString());
|
||||
}
|
||||
public String getMethod();
|
||||
public HttpScheme getScheme();
|
||||
public String getHost();
|
||||
public int getPort();
|
||||
public HttpURI getURI();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public static class Response extends MetaData
|
||||
public interface Response extends MetaData
|
||||
{
|
||||
private final int _status;
|
||||
|
||||
public Response(HttpVersion version, int status, HttpFields fields)
|
||||
{
|
||||
super(version,fields);
|
||||
_status=status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResponse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return 31 * _status + super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Response))
|
||||
return false;
|
||||
Response that = (Response)o;
|
||||
if (_status != that._status)
|
||||
return false;
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("HTTP/2 %d%s%s", getStatus(), System.lineSeparator(), super.toString());
|
||||
}
|
||||
public int getStatus();
|
||||
}
|
||||
}
|
||||
|
@ -18,22 +18,10 @@
|
||||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,9 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
|
@ -18,6 +18,13 @@
|
||||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.hamcrest.Matchers.either;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -31,13 +38,6 @@ import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import static org.hamcrest.Matchers.either;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class HttpGeneratorServerHTTPTest
|
||||
{
|
||||
|
@ -18,6 +18,12 @@
|
||||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
|
||||
@ -25,12 +31,6 @@ import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class HttpGeneratorServerTest
|
||||
{
|
||||
@Test
|
||||
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
@ -108,6 +109,6 @@ public class AbstractTest
|
||||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
String authority = host + ":" + port;
|
||||
return new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, method, new HostPortHttpField(authority), path, fields);
|
||||
return new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, method, new HostPortHttpField(authority), path, fields);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
@ -72,7 +73,7 @@ public class FlowControlTest extends AbstractTest
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Response response = new MetaData.Response(HttpVersion.HTTP_2, 200, fields);
|
||||
MetaData.Response response = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, fields);
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), response, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
|
||||
@ -150,7 +151,7 @@ public class FlowControlTest extends AbstractTest
|
||||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
|
||||
@ -242,7 +243,7 @@ public class FlowControlTest extends AbstractTest
|
||||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return new Stream.Listener.Adapter()
|
||||
@ -347,7 +348,7 @@ public class FlowControlTest extends AbstractTest
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
// For every stream, send down half the window size of data.
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.allocate(windowSize / 2), true);
|
||||
@ -429,7 +430,7 @@ public class FlowControlTest extends AbstractTest
|
||||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
DataFrame dataFrame = new DataFrame(stream.getId(), ByteBuffer.wrap(data), true);
|
||||
|
@ -24,11 +24,13 @@ import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
@ -60,7 +62,7 @@ public class IdleTimeoutTest extends AbstractTest
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return null;
|
||||
@ -143,7 +145,7 @@ public class IdleTimeoutTest extends AbstractTest
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
Thread.sleep(2 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return null;
|
||||
@ -202,7 +204,7 @@ public class IdleTimeoutTest extends AbstractTest
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return null;
|
||||
@ -277,7 +279,7 @@ public class IdleTimeoutTest extends AbstractTest
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return null;
|
||||
|
@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
@ -99,7 +100,7 @@ public class StreamResetTest extends AbstractTest
|
||||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response response = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response response = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), response, null, false);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return new Stream.Listener.Adapter()
|
||||
|
@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@ -50,7 +51,7 @@ public class HeadersGenerateParseTest
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
|
||||
final List<HeadersFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
@ -116,7 +117,7 @@ public class HeadersGenerateParseTest
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateHeaders(lease, streamId, metaData, false);
|
||||
|
@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@ -62,7 +63,7 @@ public class PushPromiseGenerateParseTest
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
for (int i = 0; i < 2; ++i)
|
||||
@ -118,7 +119,7 @@ public class PushPromiseGenerateParseTest
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);
|
||||
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@ -136,10 +137,10 @@ public class MetaDataBuilder
|
||||
HttpFields fields = _fields;
|
||||
_fields = new HttpFields(Math.max(10,fields.size()+5));
|
||||
if (_method!=null)
|
||||
return new MetaData.Request(HttpVersion.HTTP_2,_scheme,_method,_authority,_path,fields);
|
||||
return new FinalMetaData.Request(HttpVersion.HTTP_2,_scheme,_method,_authority,_path,fields);
|
||||
if (_status!=0)
|
||||
return new MetaData.Response(HttpVersion.HTTP_2,_status,fields);
|
||||
return new MetaData(HttpVersion.HTTP_2,fields);
|
||||
return new FinalMetaData.Response(HttpVersion.HTTP_2,_status,fields);
|
||||
return new FinalMetaData(HttpVersion.HTTP_2,fields);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ package org.eclipse.jetty.http2.hpack;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
@ -70,7 +71,7 @@ public class HpackEncoderTest
|
||||
// encode them
|
||||
ByteBuffer buffer = BufferUtil.allocate(4096);
|
||||
int pos = BufferUtil.flipToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,pos);
|
||||
|
||||
// something was encoded!
|
||||
@ -89,7 +90,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode exact same fields again!
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// nothing should be encoded!
|
||||
@ -112,7 +113,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
@ -136,7 +137,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
@ -163,7 +164,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
@ -191,7 +192,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
@ -225,7 +226,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
@ -246,7 +247,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
@ -258,7 +259,7 @@ public class HpackEncoderTest
|
||||
|
||||
// encode again
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -24,16 +24,16 @@ import static org.junit.Assert.assertEquals;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.eclipse.jetty.http.MetaData.Request;
|
||||
import org.eclipse.jetty.http.MetaData.Response;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class HpackTest
|
||||
@ -51,7 +51,7 @@ public class HpackTest
|
||||
fields0.add(HttpHeader.SERVER,"jetty");
|
||||
fields0.add(HttpHeader.SET_COOKIE,"abcdefghijklmnopqrstuvwxyz");
|
||||
fields0.add("custom-key","custom-value");
|
||||
Response original0 = new Response(HttpVersion.HTTP_2,200,fields0);
|
||||
Response original0 = new FinalMetaData.Response(HttpVersion.HTTP_2,200,fields0);
|
||||
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,original0);
|
||||
@ -73,7 +73,7 @@ public class HpackTest
|
||||
fields1.add(HttpHeader.CONTENT_LENGTH,"1234");
|
||||
fields1.add(HttpHeader.SERVER,"jetty");
|
||||
fields1.add("Custom-Key","Other-Value");
|
||||
Response original1 = new Response(HttpVersion.HTTP_2,200,fields1);
|
||||
Response original1 = new FinalMetaData.Response(HttpVersion.HTTP_2,200,fields1);
|
||||
|
||||
// Same again?
|
||||
BufferUtil.clearToFill(buffer);
|
||||
@ -97,7 +97,7 @@ public class HpackTest
|
||||
HttpFields fields0 = new HttpFields();
|
||||
fields0.add("1234567890","1234567890123456789012345678901234567890");
|
||||
fields0.add("Cookie","abcdeffhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR");
|
||||
MetaData original0= new MetaData(HttpVersion.HTTP_2,fields0);
|
||||
MetaData original0= new FinalMetaData(HttpVersion.HTTP_2,fields0);
|
||||
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,original0);
|
||||
@ -110,7 +110,7 @@ public class HpackTest
|
||||
fields1.add("1234567890","1234567890123456789012345678901234567890");
|
||||
fields1.add("Cookie","abcdeffhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR");
|
||||
fields1.add("x","y");
|
||||
MetaData original1 = new MetaData(HttpVersion.HTTP_2,fields1);
|
||||
MetaData original1 = new FinalMetaData(HttpVersion.HTTP_2,fields1);
|
||||
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,original1);
|
||||
|
@ -0,0 +1,3 @@
|
||||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.http2.LEVEL=DEBUG
|
||||
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.http2.server;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
@ -81,7 +82,7 @@ public class HttpTransportOverHTTP2 implements HttpTransport
|
||||
System.lineSeparator(), info.getHttpFields());
|
||||
}
|
||||
|
||||
MetaData metaData = new MetaData.Response(HttpVersion.HTTP_2, info.getStatus(), info.getHttpFields());
|
||||
MetaData metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, info.getStatus(), info.getHttpFields());
|
||||
HeadersFrame frame = new HeadersFrame(stream.getId(), metaData, null, endStream);
|
||||
stream.headers(frame, callback);
|
||||
}
|
||||
|
@ -28,11 +28,13 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
@ -98,7 +100,7 @@ public class HTTP2ServerTest
|
||||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
new HostPortHttpField(host + ":" + port), path, fields);
|
||||
HeadersFrame request = new HeadersFrame(1, metaData, null, true);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
@ -147,7 +149,7 @@ public class HTTP2ServerTest
|
||||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
new HostPortHttpField(host + ":" + port), path, fields);
|
||||
HeadersFrame request = new HeadersFrame(1, metaData, null, true);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
@ -210,7 +212,7 @@ public class HTTP2ServerTest
|
||||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Request metaData = new MetaData.Request(HttpVersion.HTTP_2,HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2,HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
new HostPortHttpField(host + ":" + port), path, fields);
|
||||
HeadersFrame request = new HeadersFrame(1, metaData, null, true);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
|
@ -22,22 +22,20 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
@ -49,7 +47,6 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ErrorHandler;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.SharedBlockingCallback.Blocker;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
@ -100,7 +97,6 @@ public class HttpChannel implements Runnable
|
||||
private final HttpChannelState _state;
|
||||
private final Request _request;
|
||||
private final Response _response;
|
||||
private HttpVersion _version = HttpVersion.HTTP_1_1;
|
||||
|
||||
public HttpChannel(Connector connector, HttpConfiguration configuration, EndPoint endPoint, HttpTransport transport, HttpInput input)
|
||||
{
|
||||
@ -120,10 +116,6 @@ public class HttpChannel implements Runnable
|
||||
return _state;
|
||||
}
|
||||
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
/**
|
||||
* @return the number of requests handled by this connection
|
||||
*/
|
||||
@ -458,60 +450,9 @@ public class HttpChannel implements Runnable
|
||||
public void onRequest(MetaData.Request request)
|
||||
{
|
||||
_requests.incrementAndGet();
|
||||
// TODO directly inject MetaData.Request to Request
|
||||
|
||||
|
||||
_request.setTimeStamp(System.currentTimeMillis());
|
||||
|
||||
_request.setHttpVersion(_version = request.getHttpVersion());
|
||||
_request.setMethod(request.getMethod());
|
||||
_request.setScheme(request.getScheme().asString());
|
||||
|
||||
HttpURI uri = request.getURI();
|
||||
|
||||
String uriHost=uri.getHost();
|
||||
if (uriHost!=null)
|
||||
{
|
||||
// Give precidence to authority in absolute URI
|
||||
_request.setServerName(uriHost);
|
||||
_request.setServerPort(uri.getPort());
|
||||
}
|
||||
else
|
||||
{
|
||||
_request.setServerName(request.getHost());
|
||||
_request.setServerPort(request.getPort());
|
||||
}
|
||||
|
||||
_request.setUri(request.getURI());
|
||||
|
||||
|
||||
String path;
|
||||
try
|
||||
{
|
||||
path = uri.getDecodedPath();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Failed UTF-8 decode for request path, trying ISO-8859-1");
|
||||
LOG.ignore(e);
|
||||
path = uri.getDecodedPath(StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
String info = URIUtil.canonicalPath(path); // TODO should this be done prior to decoding???
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
if( path==null && uri.getScheme()!=null && uri.getHost()!=null)
|
||||
{
|
||||
info = "/";
|
||||
_request.setRequestURI("");
|
||||
}
|
||||
else
|
||||
throw new BadMessageException(400,"Bad URI");
|
||||
}
|
||||
_request.setPathInfo(info);
|
||||
|
||||
// TODO avoid playing in headers
|
||||
_request.getHttpFields().addAll(request.getFields());
|
||||
_request.setMetaData(request);
|
||||
|
||||
// TODO make this a better field for h2 hpack generation
|
||||
if (_configuration.getSendDateHeader())
|
||||
|
@ -23,6 +23,8 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.AbstractMetaData;
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@ -31,6 +33,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
@ -55,6 +58,54 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
||||
private boolean _expect = false;
|
||||
private boolean _expect100Continue = false;
|
||||
private boolean _expect102Processing = false;
|
||||
private final MetaData.Request _metadata = new AbstractMetaData.Request()
|
||||
{
|
||||
@Override
|
||||
public String getMethod()
|
||||
{
|
||||
return _method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpScheme getScheme()
|
||||
{
|
||||
String scheme = _uri.getScheme();
|
||||
if (scheme==null || !scheme.endsWith("s"))
|
||||
return HttpScheme.HTTP;
|
||||
return HttpScheme.HTTPS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost()
|
||||
{
|
||||
return _hostPort==null?null:_hostPort.getHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort()
|
||||
{
|
||||
return _hostPort==null?0:_hostPort.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpURI getURI()
|
||||
{
|
||||
return _uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpFields getFields()
|
||||
{
|
||||
return _fields;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public HttpChannelOverHttp(HttpConnection httpConnection, Connector connector, HttpConfiguration config, EndPoint endPoint, HttpTransport transport, HttpInput input)
|
||||
{
|
||||
@ -295,7 +346,7 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
||||
if (!persistent)
|
||||
_httpConnection._generator.setPersistent(false);
|
||||
|
||||
onRequest(new MetaData.Request(_version,_method,_uri,_fields,_hostPort));
|
||||
onRequest(_metadata);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpUpgradeHandler;
|
||||
import javax.servlet.http.Part;
|
||||
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
@ -69,6 +70,7 @@ import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler.Context;
|
||||
@ -127,10 +129,10 @@ public class Request implements HttpServletRequest
|
||||
private static final int __NONE = 0, _STREAM = 1, __READER = 2;
|
||||
|
||||
private final HttpChannel _channel;
|
||||
private final HttpFields _fields=new HttpFields();
|
||||
private final List<ServletRequestAttributeListener> _requestAttributeListeners=new ArrayList<>();
|
||||
private final HttpInput _input;
|
||||
|
||||
private MetaData.Request _metadata;
|
||||
private boolean _secure;
|
||||
private boolean _asyncSupported = true;
|
||||
private boolean _newContext;
|
||||
@ -152,7 +154,6 @@ public class Request implements HttpServletRequest
|
||||
private MultiMap<String> _parameters;
|
||||
private String _pathInfo;
|
||||
private int _serverPort;
|
||||
private HttpVersion _httpVersion = HttpVersion.HTTP_1_1;
|
||||
private String _queryEncoding;
|
||||
private String _queryString;
|
||||
private BufferedReader _reader;
|
||||
@ -182,7 +183,7 @@ public class Request implements HttpServletRequest
|
||||
/* ------------------------------------------------------------ */
|
||||
public HttpFields getHttpFields()
|
||||
{
|
||||
return _fields;
|
||||
return _metadata.getFields();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -200,6 +201,7 @@ public class Request implements HttpServletRequest
|
||||
throw new IllegalArgumentException(listener.getClass().toString());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void extractParameters()
|
||||
{
|
||||
if (_paramsExtracted)
|
||||
@ -221,6 +223,7 @@ public class Request implements HttpServletRequest
|
||||
_parameters = restoreParameters();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private MultiMap<String> extractQueryParameters()
|
||||
{
|
||||
MultiMap<String> result = new MultiMap<>();
|
||||
@ -248,6 +251,7 @@ public class Request implements HttpServletRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private MultiMap<String> extractContentParameters()
|
||||
{
|
||||
MultiMap<String> result = new MultiMap<>();
|
||||
@ -276,6 +280,7 @@ public class Request implements HttpServletRequest
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void extractFormParameters(MultiMap<String> params)
|
||||
{
|
||||
try
|
||||
@ -341,6 +346,7 @@ public class Request implements HttpServletRequest
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private void extractMultipartParameters(MultiMap<String> result)
|
||||
{
|
||||
try
|
||||
@ -480,7 +486,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public int getContentLength()
|
||||
{
|
||||
return (int)_fields.getLongField(HttpHeader.CONTENT_LENGTH.toString());
|
||||
return (int)_metadata.getFields().getLongField(HttpHeader.CONTENT_LENGTH.toString());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -490,7 +496,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public long getContentLengthLong()
|
||||
{
|
||||
return _fields.getLongField(HttpHeader.CONTENT_LENGTH.toString());
|
||||
return _metadata.getFields().getLongField(HttpHeader.CONTENT_LENGTH.toString());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -506,7 +512,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public String getContentType()
|
||||
{
|
||||
String content_type = _fields.getStringField(HttpHeader.CONTENT_TYPE);
|
||||
String content_type = _metadata.getFields().getStringField(HttpHeader.CONTENT_TYPE);
|
||||
if (_characterEncoding==null && content_type!=null)
|
||||
{
|
||||
MimeTypes.Type mime = MimeTypes.CACHE.get(content_type);
|
||||
@ -543,7 +549,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public Cookie[] getCookies()
|
||||
{
|
||||
if (_cookiesExtracted)
|
||||
if (_metadata==null || _cookiesExtracted)
|
||||
{
|
||||
if (_cookies == null || _cookies.getCookies().length == 0)
|
||||
return null;
|
||||
@ -553,7 +559,7 @@ public class Request implements HttpServletRequest
|
||||
|
||||
_cookiesExtracted = true;
|
||||
|
||||
Enumeration<?> enm = _fields.getValues(HttpHeader.COOKIE.toString());
|
||||
Enumeration<?> enm = _metadata.getFields().getValues(HttpHeader.COOKIE.toString());
|
||||
|
||||
// Handle no cookies
|
||||
if (enm != null)
|
||||
@ -582,7 +588,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public long getDateHeader(String name)
|
||||
{
|
||||
return _fields.getDateField(name);
|
||||
return _metadata==null?-1:_metadata.getFields().getDateField(name);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -599,7 +605,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public String getHeader(String name)
|
||||
{
|
||||
return _fields.getStringField(name);
|
||||
return _metadata==null?null:_metadata.getFields().getStringField(name);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -609,7 +615,9 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public Enumeration<String> getHeaderNames()
|
||||
{
|
||||
return _fields.getFieldNames();
|
||||
if (_metadata==null)
|
||||
return Collections.emptyEnumeration();
|
||||
return _metadata.getFields().getFieldNames();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -619,7 +627,9 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name)
|
||||
{
|
||||
Enumeration<String> e = _fields.getValues(name);
|
||||
if (_metadata==null)
|
||||
return Collections.emptyEnumeration();
|
||||
Enumeration<String> e = _metadata.getFields().getValues(name);
|
||||
if (e == null)
|
||||
return Collections.enumeration(Collections.<String>emptyList());
|
||||
return e;
|
||||
@ -658,7 +668,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public int getIntHeader(String name)
|
||||
{
|
||||
return (int)_fields.getLongField(name);
|
||||
return _metadata==null?-1:(int)_metadata.getFields().getLongField(name);
|
||||
}
|
||||
|
||||
|
||||
@ -669,7 +679,10 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public Locale getLocale()
|
||||
{
|
||||
Enumeration<String> enm = _fields.getValues(HttpHeader.ACCEPT_LANGUAGE.toString(),HttpFields.__separators);
|
||||
if (_metadata==null)
|
||||
return Locale.getDefault();
|
||||
|
||||
Enumeration<String> enm = _metadata.getFields().getValues(HttpHeader.ACCEPT_LANGUAGE.toString(),HttpFields.__separators);
|
||||
|
||||
// handle no locale
|
||||
if (enm == null || !enm.hasMoreElements())
|
||||
@ -706,8 +719,10 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public Enumeration<Locale> getLocales()
|
||||
{
|
||||
|
||||
Enumeration<String> enm = _fields.getValues(HttpHeader.ACCEPT_LANGUAGE.toString(),HttpFields.__separators);
|
||||
if (_metadata==null)
|
||||
return Collections.enumeration(__defaultLocale);
|
||||
|
||||
Enumeration<String> enm = _metadata.getFields().getValues(HttpHeader.ACCEPT_LANGUAGE.toString(),HttpFields.__separators);
|
||||
|
||||
// handle no locale
|
||||
if (enm == null || !enm.hasMoreElements())
|
||||
@ -907,7 +922,7 @@ public class Request implements HttpServletRequest
|
||||
@Override
|
||||
public String getProtocol()
|
||||
{
|
||||
return _httpVersion.toString();
|
||||
return _metadata==null?null:_metadata.getHttpVersion().toString();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -916,7 +931,7 @@ public class Request implements HttpServletRequest
|
||||
*/
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _httpVersion;
|
||||
return _metadata==null?null:_metadata.getHttpVersion();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -1181,7 +1196,7 @@ public class Request implements HttpServletRequest
|
||||
}
|
||||
|
||||
// Return host from header field
|
||||
HttpField host = _fields.getField(HttpHeader.HOST);
|
||||
HttpField host = _metadata.getFields().getField(HttpHeader.HOST);
|
||||
if (host!=null)
|
||||
{
|
||||
HostPortHttpField authority = (host instanceof HostPortHttpField)
|
||||
@ -1518,9 +1533,67 @@ public class Request implements HttpServletRequest
|
||||
return _savedNewSessions.get(key);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param request
|
||||
*/
|
||||
public void setMetaData(org.eclipse.jetty.http.MetaData.Request request)
|
||||
{
|
||||
_metadata=request;
|
||||
setMethod(request.getMethod());
|
||||
setScheme(request.getScheme().asString());
|
||||
|
||||
HttpURI uri = request.getURI();
|
||||
|
||||
String uriHost=uri.getHost();
|
||||
if (uriHost!=null)
|
||||
{
|
||||
// Give precidence to authority in absolute URI
|
||||
setServerName(uriHost);
|
||||
setServerPort(uri.getPort());
|
||||
}
|
||||
else
|
||||
{
|
||||
setServerName(request.getHost());
|
||||
setServerPort(request.getPort());
|
||||
}
|
||||
|
||||
setUri(request.getURI());
|
||||
|
||||
|
||||
String path;
|
||||
try
|
||||
{
|
||||
path = uri.getDecodedPath();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Failed UTF-8 decode for request path, trying ISO-8859-1");
|
||||
LOG.ignore(e);
|
||||
path = uri.getDecodedPath(StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
String info = URIUtil.canonicalPath(path); // TODO should this be done prior to decoding???
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
if( path==null && uri.getScheme()!=null && uri.getHost()!=null)
|
||||
{
|
||||
info = "/";
|
||||
setRequestURI("");
|
||||
}
|
||||
else
|
||||
throw new BadMessageException(400,"Bad URI");
|
||||
}
|
||||
setPathInfo(info);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void recycle()
|
||||
{
|
||||
_metadata=null;
|
||||
|
||||
if (_context != null)
|
||||
throw new IllegalStateException("Request in context!");
|
||||
|
||||
@ -1560,7 +1633,6 @@ public class Request implements HttpServletRequest
|
||||
_httpMethod = null;
|
||||
_pathInfo = null;
|
||||
_serverPort = 0;
|
||||
_httpVersion = HttpVersion.HTTP_1_1;
|
||||
_queryEncoding = null;
|
||||
_queryString = null;
|
||||
_requestedSessionId = null;
|
||||
@ -1585,7 +1657,6 @@ public class Request implements HttpServletRequest
|
||||
_savedNewSessions=null;
|
||||
_multiPartInputStream = null;
|
||||
_remote=null;
|
||||
_fields.clear();
|
||||
_input.recycle();
|
||||
}
|
||||
|
||||
@ -1728,8 +1799,7 @@ public class Request implements HttpServletRequest
|
||||
*/
|
||||
public void setContentType(String contentType)
|
||||
{
|
||||
_fields.put(HttpHeader.CONTENT_TYPE,contentType);
|
||||
|
||||
_metadata.getFields().put(HttpHeader.CONTENT_TYPE,contentType);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ -1818,16 +1888,6 @@ public class Request implements HttpServletRequest
|
||||
_pathInfo = pathInfo;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param version
|
||||
* The protocol to set.
|
||||
*/
|
||||
public void setHttpVersion(HttpVersion version)
|
||||
{
|
||||
_httpVersion = version;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Set the character encoding used for the query string. This call will effect the return of getQueryString and getParamaters. It must be called before any
|
||||
@ -1965,6 +2025,7 @@ public class Request implements HttpServletRequest
|
||||
* @param uri
|
||||
* The uri to set.
|
||||
*/
|
||||
@Deprecated // is this still needed or can we use meta data?
|
||||
public void setUri(HttpURI uri)
|
||||
{
|
||||
_uri = uri;
|
||||
|
@ -1218,7 +1218,8 @@ public class Response implements HttpServletResponse
|
||||
_contentLength = -1;
|
||||
_fields.clear();
|
||||
|
||||
String connection = _channel.getRequest().getHttpFields().getStringField(HttpHeader.CONNECTION);
|
||||
String connection = _channel.getRequest().getHeader(HttpHeader.CONNECTION.asString());
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
String[] values = connection.split(",");
|
||||
|
@ -399,7 +399,6 @@ public class CrossOriginFilterTest
|
||||
"Origin: http://localhost\r\n" +
|
||||
"\r\n";
|
||||
String response = tester.getResponses(request,1,TimeUnit.SECONDS);
|
||||
System.err.println(response);
|
||||
Assert.assertTrue(response.contains("HTTP/1.1 200"));
|
||||
Assert.assertFalse(response.contains(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER));
|
||||
Assert.assertFalse(response.contains(CrossOriginFilter.ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER));
|
||||
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.spdy.server.http;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.FinalMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
@ -163,7 +164,7 @@ public class HttpChannelOverSPDY extends HttpChannel
|
||||
// At last, add the Host header.
|
||||
fields.add(hostPort);
|
||||
|
||||
MetaData.Request request = new MetaData.Request(httpVersion, httpMethod.asString(), uri, fields, hostPort);
|
||||
MetaData.Request request = new FinalMetaData.Request(httpVersion, httpMethod.asString(), uri, fields, hostPort);
|
||||
onRequest(request);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user