Major refactor of metadata and HttpURI
This refactor strives to remove duplication between the Metadata class and the HttpURI class. Both classes have been made mutable (as they partially were anyway so best not to pretend). HttpURI now holds the decomposed strings rather than a single string with indexes. This allows it to be rebuilt after changing just parts of the URI. It is now a lot more similar to the JVM URI class and we could consider replacing it (after checking peformance). Next step is to refactor the Request class to prevent it duplicating these fields.
This commit is contained in:
parent
2f41275b0f
commit
30123607c6
|
@ -23,13 +23,11 @@ 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;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
|
@ -90,7 +88,7 @@ public class HttpChannelOverFCGI extends HttpChannel
|
|||
if (query != null && query.length() > 0)
|
||||
uri += "?" + query;
|
||||
// TODO https?
|
||||
onRequest(new FinalMetaData.Request(HttpVersion.fromString(version), HttpScheme.HTTP.asString(), method, uri, fields, hostPort));
|
||||
onRequest(new MetaData.Request(method, HttpScheme.HTTP.asString(), hostPort, uri, HttpVersion.fromString(version), fields));
|
||||
}
|
||||
|
||||
private HttpField convertHeader(HttpField field)
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.net.URI;
|
|||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.net.URL;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.fcgi.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.concurrent.TimeoutException;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.fcgi.server.proxy;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.fcgi.server.proxy;
|
|||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// 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 String _uri;
|
||||
private final HostPortHttpField _hostPort;
|
||||
private final HttpScheme _scheme;
|
||||
|
||||
public Request(HttpVersion version, String scheme, String method, String uri, HttpFields fields, HostPortHttpField hostPort)
|
||||
{
|
||||
_fields=fields;
|
||||
_version=version;
|
||||
_method=method;
|
||||
_uri=uri;
|
||||
_hostPort = hostPort;
|
||||
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)
|
||||
{
|
||||
_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 String 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -564,7 +564,10 @@ public class HttpFields implements Iterable<HttpField>
|
|||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return _fields.hashCode();
|
||||
int hash=0;
|
||||
for (HttpField field:_fields)
|
||||
hash+=field.hashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.http;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
@ -50,297 +51,244 @@ import org.eclipse.jetty.util.UrlEncoded;
|
|||
*/
|
||||
public class HttpURI
|
||||
{
|
||||
private final static int
|
||||
START=0,
|
||||
AUTH_OR_PATH=1,
|
||||
SCHEME_OR_PATH=2,
|
||||
AUTH=4,
|
||||
IPV6=5,
|
||||
PORT=6,
|
||||
PATH=7,
|
||||
PARAM=8,
|
||||
QUERY=9,
|
||||
ASTERISK=10;
|
||||
private enum State {
|
||||
START,
|
||||
HOST_OR_PATH,
|
||||
SCHEME_OR_PATH,
|
||||
HOST,
|
||||
IPV6,
|
||||
PORT,
|
||||
PATH,
|
||||
PARAM,
|
||||
QUERY,
|
||||
FRAGMENT,
|
||||
ASTERISK};
|
||||
|
||||
private String _scheme;
|
||||
private String _host;
|
||||
private int _port;
|
||||
private String _path;
|
||||
private String _param;
|
||||
private String _query;
|
||||
private String _fragment;
|
||||
|
||||
boolean _partial=false;
|
||||
String _uri;
|
||||
int _scheme;
|
||||
int _authority;
|
||||
int _host;
|
||||
int _port;
|
||||
int _portValue;
|
||||
int _path;
|
||||
int _param;
|
||||
int _query;
|
||||
int _fragment;
|
||||
int _end;
|
||||
boolean _encoded=false;
|
||||
String _decodedPath;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public HttpURI()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param parsePartialAuth If True, parse auth without prior scheme, else treat all URIs starting with / as paths
|
||||
*/
|
||||
public HttpURI(boolean parsePartialAuth)
|
||||
{
|
||||
_partial=parsePartialAuth;
|
||||
}
|
||||
|
||||
public HttpURI(String uri)
|
||||
{
|
||||
_uri=uri;
|
||||
parse(uri);
|
||||
parse(State.START,uri,0,uri.length());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public HttpURI(URI uri)
|
||||
{
|
||||
this(uri.toASCIIString());
|
||||
_uri=null;
|
||||
|
||||
_scheme=uri.getScheme();
|
||||
_host=uri.getHost();
|
||||
_port=uri.getPort();
|
||||
_path=uri.getRawPath();
|
||||
_decodedPath=uri.getPath();
|
||||
int p=_path.lastIndexOf(';');
|
||||
if (p>=0)
|
||||
_param=_path.substring(p+1);
|
||||
_query=uri.getRawQuery();
|
||||
_fragment=uri.getFragment();
|
||||
|
||||
_decodedPath=null;
|
||||
}
|
||||
|
||||
|
||||
public void parseConnect(String authority)
|
||||
/* ------------------------------------------------------------ */
|
||||
public HttpURI(String scheme, String host, int port, String pathQuery)
|
||||
{
|
||||
parseConnect(authority,0,authority.length());
|
||||
_uri=null;
|
||||
|
||||
_scheme=scheme;
|
||||
_host=host;
|
||||
_port=port;
|
||||
|
||||
parse(State.PATH,pathQuery,0,pathQuery.length());
|
||||
|
||||
}
|
||||
|
||||
public void parseConnect(String authority,int offset,int length)
|
||||
/* ------------------------------------------------------------ */
|
||||
public void parse(String uri)
|
||||
{
|
||||
_uri=authority;
|
||||
_encoded=false;
|
||||
int i=offset;
|
||||
int e=offset+length;
|
||||
int state=AUTH;
|
||||
_end=offset+length;
|
||||
_scheme=offset;
|
||||
_authority=offset;
|
||||
_host=offset;
|
||||
_port=_end;
|
||||
_portValue=-1;
|
||||
_path=_end;
|
||||
_param=_end;
|
||||
_query=_end;
|
||||
_fragment=_end;
|
||||
clear();
|
||||
_uri=uri;
|
||||
parse(State.START,uri,0,uri.length());
|
||||
}
|
||||
|
||||
loop: while (i<e)
|
||||
/* ------------------------------------------------------------ */
|
||||
public void parse(String uri, int offset, int length)
|
||||
{
|
||||
clear();
|
||||
int end=offset+length;
|
||||
_uri=uri.substring(offset,end);
|
||||
parse(State.START,uri,offset,end);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private void parse(State state, final String uri, final int offset, final int end)
|
||||
{
|
||||
boolean encoded=false;
|
||||
int m=offset;
|
||||
int p=0;
|
||||
|
||||
for (int i=offset; i<end; i++)
|
||||
{
|
||||
char c=authority.charAt(i);
|
||||
int s=i++;
|
||||
char c=uri.charAt(i);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case AUTH:
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case ':':
|
||||
{
|
||||
_port = s;
|
||||
break loop;
|
||||
}
|
||||
case '[':
|
||||
{
|
||||
state = IPV6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
case IPV6:
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '/':
|
||||
{
|
||||
throw new IllegalArgumentException("No closing ']' for " + _uri.substring(offset,length));
|
||||
}
|
||||
case ']':
|
||||
{
|
||||
state = AUTH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_port<_path)
|
||||
_portValue=TypeUtil.parseInt(_uri, _port+1, _path-_port-1,10);
|
||||
else
|
||||
throw new IllegalArgumentException("No port");
|
||||
_path=offset;
|
||||
}
|
||||
|
||||
|
||||
public void parse(String uri)
|
||||
{
|
||||
_uri=uri;
|
||||
_encoded=false;
|
||||
int i=0;
|
||||
int e=uri.length();
|
||||
int state=START;
|
||||
int m=i;
|
||||
_end=e;
|
||||
_scheme=i;
|
||||
_authority=i;
|
||||
_host=i;
|
||||
_port=i;
|
||||
_portValue=-1;
|
||||
_path=i;
|
||||
_param=_end;
|
||||
_query=_end;
|
||||
_fragment=_end;
|
||||
while (i<e)
|
||||
{
|
||||
char c=uri.charAt(i);
|
||||
int s=i++;
|
||||
|
||||
state: switch (state)
|
||||
{
|
||||
case START:
|
||||
{
|
||||
m=s;
|
||||
switch(c)
|
||||
{
|
||||
case '/':
|
||||
state=AUTH_OR_PATH;
|
||||
p=m=i;
|
||||
state=State.PATH;
|
||||
break;
|
||||
case ';':
|
||||
_param=s;
|
||||
state=PARAM;
|
||||
m=i+1;
|
||||
state=State.PARAM;
|
||||
break;
|
||||
case '?':
|
||||
_param=s;
|
||||
_query=s;
|
||||
state=QUERY;
|
||||
m=i+1;
|
||||
state=State.QUERY;
|
||||
break;
|
||||
case '#':
|
||||
_param=s;
|
||||
_query=s;
|
||||
_fragment=s;
|
||||
m=i+1;
|
||||
state=State.FRAGMENT;
|
||||
break;
|
||||
case '*':
|
||||
_path=s;
|
||||
state=ASTERISK;
|
||||
_path="*";
|
||||
state=State.ASTERISK;
|
||||
break;
|
||||
|
||||
default:
|
||||
state=SCHEME_OR_PATH;
|
||||
m=i;
|
||||
state=State.SCHEME_OR_PATH;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
case AUTH_OR_PATH:
|
||||
{
|
||||
if ((_partial||_scheme!=_authority) && c=='/')
|
||||
{
|
||||
_host=i;
|
||||
_port=_end;
|
||||
_path=_end;
|
||||
state=AUTH;
|
||||
}
|
||||
else if (c==';' || c=='?' || c=='#')
|
||||
{
|
||||
i--;
|
||||
state=PATH;
|
||||
}
|
||||
else
|
||||
{
|
||||
_host=m;
|
||||
_port=m;
|
||||
state=PATH;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
case SCHEME_OR_PATH:
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case ':':
|
||||
{
|
||||
m = i++;
|
||||
_authority = m;
|
||||
_path = m;
|
||||
c = uri.charAt(i);
|
||||
// must have been a scheme
|
||||
_scheme=uri.substring(m,i);
|
||||
c = uri.charAt(++i);
|
||||
m=i;
|
||||
if (c == '/')
|
||||
state = AUTH_OR_PATH;
|
||||
state=State.HOST_OR_PATH;
|
||||
else
|
||||
{
|
||||
_host = m;
|
||||
_port = m;
|
||||
state = PATH;
|
||||
}
|
||||
state=State.PATH;
|
||||
break;
|
||||
}
|
||||
|
||||
case '/':
|
||||
{
|
||||
state = PATH;
|
||||
// must have been in a path and still are
|
||||
state=State.PATH;
|
||||
break;
|
||||
}
|
||||
|
||||
case ';':
|
||||
{
|
||||
_param = s;
|
||||
state = PARAM;
|
||||
// must have been in a path
|
||||
p=m;
|
||||
state=State.PARAM;
|
||||
break;
|
||||
}
|
||||
|
||||
case '?':
|
||||
{
|
||||
_param = s;
|
||||
_query = s;
|
||||
state = QUERY;
|
||||
// must have been in a path
|
||||
_path=uri.substring(m,i);
|
||||
state=State.QUERY;
|
||||
break;
|
||||
}
|
||||
|
||||
case '%':
|
||||
{
|
||||
encoded=true;
|
||||
}
|
||||
|
||||
case '#':
|
||||
{
|
||||
_param = s;
|
||||
_query = s;
|
||||
_fragment = s;
|
||||
// must have been in a path
|
||||
_path=uri.substring(m,i);
|
||||
state=State.FRAGMENT;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
case AUTH:
|
||||
case HOST_OR_PATH:
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case '/':
|
||||
m=i+1;
|
||||
state=State.HOST;
|
||||
break;
|
||||
|
||||
case ';':
|
||||
case '?':
|
||||
case '#':
|
||||
// was a path, look again
|
||||
i--;
|
||||
p=m;
|
||||
state=State.PATH;
|
||||
break;
|
||||
default:
|
||||
// it is a path
|
||||
p=m;
|
||||
state=State.PATH;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
case HOST:
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
|
||||
case '/':
|
||||
{
|
||||
m = s;
|
||||
_path = m;
|
||||
_port = _path;
|
||||
state = PATH;
|
||||
break;
|
||||
}
|
||||
case '@':
|
||||
{
|
||||
_host = i;
|
||||
_host=uri.substring(m,i);
|
||||
p=m=i;
|
||||
state=State.PATH;
|
||||
break;
|
||||
}
|
||||
case ':':
|
||||
{
|
||||
_port = s;
|
||||
state = PORT;
|
||||
_host=uri.substring(m,i);
|
||||
m=i+1;
|
||||
state=State.PORT;
|
||||
break;
|
||||
}
|
||||
case '@':
|
||||
// ignore user
|
||||
m=i+1;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
{
|
||||
state = IPV6;
|
||||
state=State.IPV6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +305,18 @@ public class HttpURI
|
|||
}
|
||||
case ']':
|
||||
{
|
||||
state = AUTH;
|
||||
c = uri.charAt(++i);
|
||||
_host=uri.substring(m,i);
|
||||
if (c == ':')
|
||||
{
|
||||
m=i+1;
|
||||
state=State.PORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
p=m=i;
|
||||
state=State.PATH;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -369,11 +328,9 @@ public class HttpURI
|
|||
{
|
||||
if (c=='/')
|
||||
{
|
||||
m=s;
|
||||
_path=m;
|
||||
if (_port<=_authority)
|
||||
_port=_path;
|
||||
state=PATH;
|
||||
_port=TypeUtil.parseInt(uri,m,i-m,10);
|
||||
p=m=i;
|
||||
state=State.PATH;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -384,27 +341,27 @@ public class HttpURI
|
|||
{
|
||||
case ';':
|
||||
{
|
||||
_param = s;
|
||||
state = PARAM;
|
||||
m=i+1;
|
||||
state=State.PARAM;
|
||||
break;
|
||||
}
|
||||
case '?':
|
||||
{
|
||||
_param = s;
|
||||
_query = s;
|
||||
state = QUERY;
|
||||
_path=uri.substring(p,i);
|
||||
m=i+1;
|
||||
state=State.QUERY;
|
||||
break;
|
||||
}
|
||||
case '#':
|
||||
{
|
||||
_param = s;
|
||||
_query = s;
|
||||
_fragment = s;
|
||||
break state;
|
||||
_path=uri.substring(p,i);
|
||||
m=i+1;
|
||||
state=State.FRAGMENT;
|
||||
break;
|
||||
}
|
||||
case '%':
|
||||
{
|
||||
_encoded=true;
|
||||
encoded=true;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
@ -416,20 +373,26 @@ public class HttpURI
|
|||
{
|
||||
case '?':
|
||||
{
|
||||
_query = s;
|
||||
state = QUERY;
|
||||
_path=uri.substring(p,i);
|
||||
_param=uri.substring(m,i);
|
||||
m=i+1;
|
||||
state=State.QUERY;
|
||||
break;
|
||||
}
|
||||
case '#':
|
||||
{
|
||||
_query = s;
|
||||
_fragment = s;
|
||||
break state;
|
||||
_path=uri.substring(p,i);
|
||||
_param=uri.substring(m,i);
|
||||
m=i+1;
|
||||
state=State.FRAGMENT;
|
||||
break;
|
||||
}
|
||||
case '/':
|
||||
{
|
||||
state=PATH;
|
||||
break state;
|
||||
encoded=true;
|
||||
// ignore internal params
|
||||
state=State.PATH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
@ -439,8 +402,9 @@ public class HttpURI
|
|||
{
|
||||
if (c=='#')
|
||||
{
|
||||
_fragment=s;
|
||||
break state;
|
||||
_query=uri.substring(m,i);
|
||||
m=i+1;
|
||||
state=State.FRAGMENT;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -449,138 +413,208 @@ public class HttpURI
|
|||
{
|
||||
throw new IllegalArgumentException("only '*'");
|
||||
}
|
||||
|
||||
case FRAGMENT:
|
||||
{
|
||||
_fragment=uri.substring(m,end);
|
||||
i=end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_port<_path)
|
||||
_portValue=TypeUtil.parseInt(_uri, _port+1, _path-_port-1,10);
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case START:
|
||||
break;
|
||||
case SCHEME_OR_PATH:
|
||||
_path=uri.substring(m,end);
|
||||
break;
|
||||
|
||||
case HOST_OR_PATH:
|
||||
_path=uri.substring(m,end);
|
||||
break;
|
||||
|
||||
case HOST:
|
||||
_host=uri.substring(m,end);
|
||||
break;
|
||||
|
||||
case IPV6:
|
||||
throw new IllegalArgumentException("No closing ']' for ipv6 in " + uri);
|
||||
|
||||
case PORT:
|
||||
_port=TypeUtil.parseInt(uri,m,end-m,10);
|
||||
break;
|
||||
|
||||
case ASTERISK:
|
||||
break;
|
||||
|
||||
case FRAGMENT:
|
||||
_fragment=uri.substring(m,end);
|
||||
break;
|
||||
|
||||
case PARAM:
|
||||
_path=uri.substring(p,end);
|
||||
_param=uri.substring(m,end);
|
||||
break;
|
||||
|
||||
case PATH:
|
||||
_path=uri.substring(p,end);
|
||||
break;
|
||||
|
||||
case QUERY:
|
||||
_query=uri.substring(m,end);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!encoded)
|
||||
{
|
||||
if (_param==null)
|
||||
_decodedPath=_path;
|
||||
else
|
||||
_decodedPath=_path.substring(0,_path.length()-_param.length()-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getScheme()
|
||||
{
|
||||
if (_scheme==_authority)
|
||||
return null;
|
||||
int l=_authority-_scheme;
|
||||
if (l==5 && _uri.startsWith("http:"))
|
||||
return HttpScheme.HTTP.asString();
|
||||
if (l==6 && _uri.startsWith("https:"))
|
||||
return HttpScheme.HTTPS.asString();
|
||||
|
||||
return _uri.substring(_scheme,_authority-_scheme-1);
|
||||
}
|
||||
|
||||
public String getAuthority()
|
||||
{
|
||||
if (_authority==_path)
|
||||
return null;
|
||||
return _uri.substring(_authority,_path);
|
||||
return _scheme;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getHost()
|
||||
{
|
||||
if (_host==_port)
|
||||
return null;
|
||||
return _uri.substring(_host,_port);
|
||||
return _host;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public int getPort()
|
||||
{
|
||||
return _portValue;
|
||||
return _port;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getPath()
|
||||
{
|
||||
if (_path==_query)
|
||||
return null;
|
||||
return _uri.substring(_path,_query);
|
||||
return _path;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getDecodedPath()
|
||||
{
|
||||
if (_path==_query)
|
||||
return null;
|
||||
return URIUtil.decodePath(_uri,_path,_query-_path);
|
||||
}
|
||||
|
||||
public String getPathAndParam()
|
||||
{
|
||||
if (_path==_query)
|
||||
return null;
|
||||
return _uri.substring(_path,_query);
|
||||
}
|
||||
|
||||
public String getCompletePath()
|
||||
{
|
||||
if (_path==_end)
|
||||
return null;
|
||||
return _uri.substring(_path,_end);
|
||||
if (_decodedPath==null && _path!=null)
|
||||
_decodedPath=URIUtil.decodePath(_path);
|
||||
return _decodedPath;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getParam()
|
||||
{
|
||||
if (_param==_query)
|
||||
return null;
|
||||
return _uri.substring(_param+1,_query);
|
||||
return _param;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getQuery()
|
||||
{
|
||||
if (_query==_fragment)
|
||||
return null;
|
||||
return _uri.substring(_query+1,_fragment);
|
||||
return _query;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean hasQuery()
|
||||
{
|
||||
return (_fragment>_query);
|
||||
return _query!=null && _query.length()>0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getFragment()
|
||||
{
|
||||
if (_fragment==_end)
|
||||
return null;
|
||||
|
||||
return _uri.substring(_fragment+1,_end);
|
||||
return _fragment;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void decodeQueryTo(MultiMap<String> parameters)
|
||||
{
|
||||
if (_query==_fragment)
|
||||
return;
|
||||
UrlEncoded.decodeUtf8To(_uri,_query+1,_fragment-_query-1,parameters);
|
||||
UrlEncoded.decodeUtf8To(_query,parameters);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void decodeQueryTo(MultiMap<String> parameters, String encoding) throws UnsupportedEncodingException
|
||||
{
|
||||
if (_query==_fragment)
|
||||
return;
|
||||
decodeQueryTo(parameters,Charset.forName(encoding));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void decodeQueryTo(MultiMap<String> parameters, Charset encoding) throws UnsupportedEncodingException
|
||||
{
|
||||
if (_query==_fragment)
|
||||
return;
|
||||
|
||||
if (encoding==null || StandardCharsets.UTF_8.equals(encoding))
|
||||
UrlEncoded.decodeUtf8To(_uri,_query+1,_fragment-_query-1,parameters);
|
||||
UrlEncoded.decodeUtf8To(_query,parameters);
|
||||
else
|
||||
UrlEncoded.decodeTo(_uri.substring(_query+1,_fragment-_query-1),parameters,encoding);
|
||||
UrlEncoded.decodeTo(_query,parameters,encoding);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void clear()
|
||||
{
|
||||
_scheme=_authority=_host=_port=_path=_param=_query=_fragment=_end=0;
|
||||
_uri=null;
|
||||
_encoded=false;
|
||||
|
||||
_scheme=null;
|
||||
_host=null;
|
||||
_port=-1;
|
||||
_path=null;
|
||||
_param=null;
|
||||
_query=null;
|
||||
_fragment=null;
|
||||
|
||||
_decodedPath=null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isAbsolute()
|
||||
{
|
||||
return _scheme!=null && _scheme.length()>0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if (_uri==null)
|
||||
{
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
if (_scheme!=null)
|
||||
out.append(_scheme).append(':');
|
||||
|
||||
if (_host!=null)
|
||||
out.append("//").append(_host);
|
||||
|
||||
if (_port>0)
|
||||
out.append(':').append(_port);
|
||||
|
||||
if (_path!=null)
|
||||
out.append(_path);
|
||||
|
||||
if (_query!=null)
|
||||
out.append('?').append(_query);
|
||||
|
||||
if (_fragment!=null)
|
||||
out.append('#').append(_fragment);
|
||||
|
||||
if (out.length()>0)
|
||||
_uri=out.toString();
|
||||
else
|
||||
_uri="";
|
||||
}
|
||||
return _uri;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o==this)
|
||||
|
@ -590,4 +624,37 @@ public class HttpURI
|
|||
return toString().equals(o.toString());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param host
|
||||
* @param port
|
||||
*/
|
||||
public void setAuth(String host, int port)
|
||||
{
|
||||
_host=host;
|
||||
_port=port;
|
||||
_uri=null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public URI toURI() throws URISyntaxException
|
||||
{
|
||||
return new URI(_scheme,null,_host,_port,_path,_query==null?null:UrlEncoded.decodeString(_query),_fragment);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getPathQuery()
|
||||
{
|
||||
if (_query==null)
|
||||
return _path;
|
||||
return _path+"?"+_query;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public String getAuthority()
|
||||
{
|
||||
if (_port>0)
|
||||
return _host+":"+_port;
|
||||
return _host;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,30 +18,299 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
public interface MetaData extends Iterable<HttpField>
|
||||
{
|
||||
public HttpVersion getHttpVersion();
|
||||
public boolean isRequest();
|
||||
public boolean isResponse();
|
||||
public HttpFields getFields();
|
||||
import java.util.Iterator;
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public interface Request extends MetaData
|
||||
public class MetaData implements Iterable<HttpField>
|
||||
{
|
||||
private HttpVersion _httpVersion;
|
||||
private HttpFields _fields;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public MetaData()
|
||||
{
|
||||
public String getMethod();
|
||||
public HttpScheme getScheme();
|
||||
public String getHost();
|
||||
public int getPort();
|
||||
public String getURI();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public MetaData(HttpVersion version, HttpFields fields)
|
||||
{
|
||||
_httpVersion = version;
|
||||
_fields = fields;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isResponse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get the httpVersion.
|
||||
* @return the httpVersion
|
||||
*/
|
||||
public HttpVersion getVersion()
|
||||
{
|
||||
return _httpVersion;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the httpVersion.
|
||||
* @param httpVersion the httpVersion to set
|
||||
*/
|
||||
public void setHttpVersion(HttpVersion httpVersion)
|
||||
{
|
||||
_httpVersion = httpVersion;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get the fields.
|
||||
* @return the fields
|
||||
*/
|
||||
public HttpFields getFields()
|
||||
{
|
||||
return _fields;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the fields.
|
||||
* @param fields the fields to set
|
||||
*/
|
||||
public void setFields(HttpFields fields)
|
||||
{
|
||||
_fields = fields;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Iterator<HttpField> iterator()
|
||||
{
|
||||
return getFields().iterator();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return 31 * getVersion().hashCode() + getFields().hashCode();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof MetaData))
|
||||
return false;
|
||||
MetaData that = (MetaData)o;
|
||||
|
||||
if (getVersion() != that.getVersion())
|
||||
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 interface Response extends MetaData
|
||||
public static class Request extends MetaData
|
||||
{
|
||||
public int getStatus();
|
||||
private String _method;
|
||||
private HttpURI _uri;
|
||||
|
||||
public Request()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param method
|
||||
* @param uri
|
||||
* @param version
|
||||
* @param fields
|
||||
*/
|
||||
public Request(String method, HttpURI uri, HttpVersion version, HttpFields fields)
|
||||
{
|
||||
super(version,fields);
|
||||
_method = method;
|
||||
_uri = uri;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Request(String method, HttpScheme scheme, HostPortHttpField hostPort, String uri, HttpVersion version, HttpFields fields)
|
||||
{
|
||||
this(method,new HttpURI(scheme==null?null:scheme.asString(),hostPort.getHost(),hostPort.getPort(),uri),version,fields);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Request(String method, String scheme, HostPortHttpField hostPort, String uri, HttpVersion version, HttpFields fields)
|
||||
{
|
||||
this(method,new HttpURI(scheme,hostPort.getHost(),hostPort.getPort(),uri),version,fields);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public boolean isRequest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get the method.
|
||||
* @return the method
|
||||
*/
|
||||
public String getMethod()
|
||||
{
|
||||
return _method;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the method.
|
||||
* @param method the method to set
|
||||
*/
|
||||
public void setMethod(String method)
|
||||
{
|
||||
_method = method;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get the uri.
|
||||
* @return the uri
|
||||
*/
|
||||
public HttpURI getURI()
|
||||
{
|
||||
return _uri;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the uri.
|
||||
* @param uri the uri to set
|
||||
*/
|
||||
public void setURI(HttpURI uri)
|
||||
{
|
||||
_uri = uri;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ((super.hashCode()*31)+_method.hashCode())*31+_uri.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()) ||
|
||||
!getURI().equals(that.getURI()))
|
||||
return false;
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s %s %s%s%s",
|
||||
getMethod(), getURI(), getVersion(), System.lineSeparator(), super.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------- */
|
||||
public static class Response extends MetaData
|
||||
{
|
||||
private int _status;
|
||||
|
||||
public Response()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param version
|
||||
* @param fields
|
||||
* @param status
|
||||
*/
|
||||
public Response(HttpVersion version, int status, HttpFields fields)
|
||||
{
|
||||
super(version,fields);
|
||||
_status=status;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public boolean isResponse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get the status.
|
||||
* @return the status
|
||||
*/
|
||||
public int getStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the status.
|
||||
* @param status the status to set
|
||||
*/
|
||||
public void setStatus(int status)
|
||||
{
|
||||
_status = status;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@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("%s %d%s%s",getVersion(), getStatus(), System.lineSeparator(), super.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -75,7 +74,8 @@ public class HttpURITest
|
|||
{
|
||||
for (String[] test:tests)
|
||||
{
|
||||
HttpURI uri = new HttpURI(new URI(test[INPUT]));
|
||||
URI u=new URI(test[INPUT]);
|
||||
HttpURI uri = new HttpURI(u);
|
||||
|
||||
assertEquals(test[SCHEME], uri.getScheme());
|
||||
assertEquals(test[HOST], uri.getHost());
|
||||
|
@ -84,67 +84,11 @@ public class HttpURITest
|
|||
assertEquals(test[PARAM], uri.getParam());
|
||||
assertEquals(test[QUERY], uri.getQuery());
|
||||
assertEquals(test[FRAGMENT], uri.getFragment());
|
||||
|
||||
assertEquals(u,uri.toURI());
|
||||
}
|
||||
}
|
||||
|
||||
private final String[][] partial_tests=
|
||||
{
|
||||
/* 0*/ {"/path/info",null,null,null,null,"/path/info",null,null,null},
|
||||
/* 1*/ {"/path/info#fragment",null,null,null,null,"/path/info",null,null,"fragment"},
|
||||
/* 2*/ {"/path/info?query",null,null,null,null,"/path/info",null,"query",null},
|
||||
/* 3*/ {"/path/info?query#fragment",null,null,null,null,"/path/info",null,"query","fragment"},
|
||||
/* 4*/ {"/path/info;param",null,null,null,null,"/path/info;param","param",null,null},
|
||||
/* 5*/ {"/path/info;param#fragment",null,null,null,null,"/path/info;param","param",null,"fragment"},
|
||||
/* 6*/ {"/path/info;param?query",null,null,null,null,"/path/info;param","param","query",null},
|
||||
/* 7*/ {"/path/info;param?query#fragment",null,null,null,null,"/path/info;param","param","query","fragment"},
|
||||
/* 8*/ {"//host/path/info",null,"//host","host",null,"/path/info",null,null,null},
|
||||
/* 9*/ {"//user@host/path/info",null,"//user@host","host",null,"/path/info",null,null,null},
|
||||
/*10*/ {"//user@host:8080/path/info",null,"//user@host:8080","host","8080","/path/info",null,null,null},
|
||||
/*11*/ {"//host:8080/path/info",null,"//host:8080","host","8080","/path/info",null,null,null},
|
||||
/*12*/ {"http:/path/info","http",null,null,null,"/path/info",null,null,null},
|
||||
/*13*/ {"http:/path/info#fragment","http",null,null,null,"/path/info",null,null,"fragment"},
|
||||
/*14*/ {"http:/path/info?query","http",null,null,null,"/path/info",null,"query",null},
|
||||
/*15*/ {"http:/path/info?query#fragment","http",null,null,null,"/path/info",null,"query","fragment"},
|
||||
/*16*/ {"http:/path/info;param","http",null,null,null,"/path/info;param","param",null,null},
|
||||
/*17*/ {"http:/path/info;param#fragment","http",null,null,null,"/path/info;param","param",null,"fragment"},
|
||||
/*18*/ {"http:/path/info;param?query","http",null,null,null,"/path/info;param","param","query",null},
|
||||
/*19*/ {"http:/path/info;param?query#fragment","http",null,null,null,"/path/info;param","param","query","fragment"},
|
||||
/*20*/ {"http://user@host:8080/path/info;param?query#fragment","http","//user@host:8080","host","8080","/path/info;param","param","query","fragment"},
|
||||
/*21*/ {"xxxxx://user@host:8080/path/info;param?query#fragment","xxxxx","//user@host:8080","host","8080","/path/info;param","param","query","fragment"},
|
||||
/*22*/ {"http:///;?#","http","//",null,null,"/;","","",""},
|
||||
/*23*/ {"/path/info?a=?query",null,null,null,null,"/path/info",null,"a=?query",null},
|
||||
/*24*/ {"/path/info?a=;query",null,null,null,null,"/path/info",null,"a=;query",null},
|
||||
/*25*/ {"//host:8080//",null,"//host:8080","host","8080","//",null,null,null},
|
||||
/*26*/ {"file:///path/info","file","//",null,null,"/path/info",null,null,null},
|
||||
/*27*/ {"//",null,"//",null,null,null,null,null,null},
|
||||
/*28*/ {"/;param",null, null, null,null,"/;param", "param",null,null},
|
||||
/*29*/ {"/?x=y",null, null, null,null,"/", null,"x=y",null},
|
||||
/*30*/ {"/?abc=test",null, null, null,null,"/", null,"abc=test",null},
|
||||
/*31*/ {"/#fragment",null, null, null,null,"/", null,null,"fragment"},
|
||||
/*32*/ {"http://localhost:8080", "http", "//localhost:8080", "localhost", "8080", null, null, null, null},
|
||||
/*33*/ {"./?foo:bar=:1:1::::",null,null,null,null,"./",null,"foo:bar=:1:1::::",null}
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testPartialURIs() throws Exception
|
||||
{
|
||||
HttpURI uri = new HttpURI(true);
|
||||
|
||||
for (int t=0;t<partial_tests.length;t++)
|
||||
{
|
||||
uri.parse(partial_tests[t][0]);
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][1],uri.getScheme());
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][2],uri.getAuthority());
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][3],uri.getHost());
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][4]==null?-1:Integer.parseInt(partial_tests[t][4]),uri.getPort());
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][5],uri.getPath());
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][6],uri.getParam());
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][7],uri.getQuery());
|
||||
assertEquals(t+" "+partial_tests[t][0],partial_tests[t][8],uri.getFragment());
|
||||
assertEquals(partial_tests[t][0], uri.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final String[][] path_tests=
|
||||
{
|
||||
|
@ -170,11 +114,11 @@ public class HttpURITest
|
|||
/*19*/ {"http:/path/info;param?query#fragment","http",null,null,null,"/path/info;param","param","query","fragment"},
|
||||
/*20*/ {"http://user@host:8080/path/info;param?query#fragment","http","//user@host:8080","host","8080","/path/info;param","param","query","fragment"},
|
||||
/*21*/ {"xxxxx://user@host:8080/path/info;param?query#fragment","xxxxx","//user@host:8080","host","8080","/path/info;param","param","query","fragment"},
|
||||
/*22*/ {"http:///;?#","http","//",null,null,"/;","","",""},
|
||||
/*22*/ {"http:///;?#","http","//","",null,"/;","","",""},
|
||||
/*23*/ {"/path/info?a=?query",null,null,null,null,"/path/info",null,"a=?query",null},
|
||||
/*24*/ {"/path/info?a=;query",null,null,null,null,"/path/info",null,"a=;query",null},
|
||||
/*25*/ {"//host:8080//",null,null,null,null,"//host:8080//",null,null,null},
|
||||
/*26*/ {"file:///path/info","file","//",null,null,"/path/info",null,null,null},
|
||||
/*26*/ {"file:///path/info","file","//","",null,"/path/info",null,null,null},
|
||||
/*27*/ {"//",null,null,null,null,"//",null,null,null},
|
||||
/*28*/ {"http://localhost/","http","//localhost","localhost",null,"/",null,null,null},
|
||||
/*29*/ {"http://localhost:8080/", "http", "//localhost:8080", "localhost","8080","/", null, null,null},
|
||||
|
@ -201,7 +145,6 @@ public class HttpURITest
|
|||
{
|
||||
uri.parse(path_tests[t][0]);
|
||||
assertEquals(t+" "+path_tests[t][0],path_tests[t][1],uri.getScheme());
|
||||
assertEquals(t+" "+path_tests[t][0],path_tests[t][2],uri.getAuthority());
|
||||
assertEquals(t+" "+path_tests[t][0],path_tests[t][3],uri.getHost());
|
||||
assertEquals(t+" "+path_tests[t][0],path_tests[t][4]==null?-1:Integer.parseInt(path_tests[t][4]),uri.getPort());
|
||||
assertEquals(t+" "+path_tests[t][0],path_tests[t][5],uri.getPath());
|
||||
|
@ -274,36 +217,6 @@ public class HttpURITest
|
|||
}
|
||||
|
||||
|
||||
private final String[][] connect_tests=
|
||||
{
|
||||
/* 0*/ {"localhost:8080","localhost","8080"},
|
||||
/* 1*/ {"127.0.0.1:8080","127.0.0.1","8080"},
|
||||
/* 2*/ {"[127::0::0::1]:8080","[127::0::0::1]","8080"},
|
||||
/* 3*/ {"error",null,null},
|
||||
/* 4*/ {"http://localhost:8080/",null,null},
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testCONNECT() throws Exception
|
||||
{
|
||||
HttpURI uri = new HttpURI();
|
||||
for (int i=0;i<connect_tests.length;i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
uri.parseConnect(connect_tests[i][0]);
|
||||
assertEquals("path"+i,connect_tests[i][0].trim(),uri.getPath());
|
||||
assertEquals("host"+i,connect_tests[i][1],uri.getHost());
|
||||
assertEquals("port"+i,Integer.parseInt(connect_tests[i][2]),uri.getPort());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
assertNull("error"+i,connect_tests[i][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParams() throws Exception
|
||||
{
|
||||
|
|
|
@ -23,7 +23,6 @@ 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;
|
||||
|
@ -109,6 +108,6 @@ public class AbstractTest
|
|||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
String authority = host + ":" + port;
|
||||
return new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, method, new HostPortHttpField(authority), path, fields);
|
||||
return new MetaData.Request(method, HttpScheme.HTTP, new HostPortHttpField(authority), path, HttpVersion.HTTP_2, fields);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ 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;
|
||||
|
@ -73,7 +72,7 @@ public class FlowControlTest extends AbstractTest
|
|||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Response response = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, fields);
|
||||
MetaData.Response response = new MetaData.Response(HttpVersion.HTTP_2, 200, fields);
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), response, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
|
||||
|
@ -151,7 +150,7 @@ public class FlowControlTest extends AbstractTest
|
|||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, false);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
|
||||
|
@ -243,7 +242,7 @@ public class FlowControlTest extends AbstractTest
|
|||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.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()
|
||||
|
@ -348,7 +347,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 FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.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);
|
||||
|
@ -430,7 +429,7 @@ public class FlowControlTest extends AbstractTest
|
|||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.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);
|
||||
|
|
|
@ -30,7 +30,6 @@ 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;
|
||||
|
@ -62,7 +61,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return null;
|
||||
|
@ -145,7 +144,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
Thread.sleep(2 * idleTimeout);
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return null;
|
||||
|
@ -204,7 +203,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
HeadersFrame responseFrame = new HeadersFrame(stream.getId(), metaData, null, true);
|
||||
stream.headers(responseFrame, Callback.Adapter.INSTANCE);
|
||||
return null;
|
||||
|
@ -279,7 +278,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
|
||||
{
|
||||
stream.setIdleTimeout(10 * idleTimeout);
|
||||
MetaData.Response metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response metaData = new MetaData.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,7 +23,6 @@ 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;
|
||||
|
@ -100,7 +99,7 @@ public class StreamResetTest extends AbstractTest
|
|||
@Override
|
||||
public Stream.Listener onNewStream(Stream stream, HeadersFrame requestFrame)
|
||||
{
|
||||
MetaData.Response response = new FinalMetaData.Response(HttpVersion.HTTP_2, 200, new HttpFields());
|
||||
MetaData.Response response = new MetaData.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,7 +22,6 @@ 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;
|
||||
|
@ -51,7 +50,7 @@ public class HeadersGenerateParseTest
|
|||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);
|
||||
|
||||
final List<HeadersFrame> frames = new ArrayList<>();
|
||||
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
|
||||
|
@ -84,10 +83,7 @@ public class HeadersGenerateParseTest
|
|||
Assert.assertEquals(streamId, frame.getStreamId());
|
||||
Assert.assertTrue(frame.isEndStream());
|
||||
MetaData.Request request = (MetaData.Request)frame.getMetaData();
|
||||
Assert.assertSame(metaData.getScheme(), request.getScheme());
|
||||
Assert.assertEquals(metaData.getMethod(), request.getMethod());
|
||||
Assert.assertEquals(metaData.getHost(), request.getHost());
|
||||
Assert.assertEquals(metaData.getPort(), request.getPort());
|
||||
Assert.assertEquals(metaData.getURI(), request.getURI());
|
||||
for (int j = 0; j < fields.size(); ++j)
|
||||
{
|
||||
|
@ -117,7 +113,7 @@ public class HeadersGenerateParseTest
|
|||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generateHeaders(lease, streamId, metaData, false);
|
||||
|
@ -135,10 +131,7 @@ public class HeadersGenerateParseTest
|
|||
Assert.assertEquals(streamId, frame.getStreamId());
|
||||
Assert.assertTrue(frame.isEndStream());
|
||||
MetaData.Request request = (MetaData.Request)frame.getMetaData();
|
||||
Assert.assertSame(metaData.getScheme(), request.getScheme());
|
||||
Assert.assertEquals(metaData.getMethod(), request.getMethod());
|
||||
Assert.assertEquals(metaData.getHost(), request.getHost());
|
||||
Assert.assertEquals(metaData.getPort(), request.getPort());
|
||||
Assert.assertEquals(metaData.getURI(), request.getURI());
|
||||
for (int j = 0; j < fields.size(); ++j)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@ 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;
|
||||
|
@ -63,7 +62,7 @@ public class PushPromiseGenerateParseTest
|
|||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);
|
||||
|
||||
// Iterate a few times to be sure generator and parser are properly reset.
|
||||
for (int i = 0; i < 2; ++i)
|
||||
|
@ -85,10 +84,7 @@ public class PushPromiseGenerateParseTest
|
|||
Assert.assertEquals(streamId, frame.getStreamId());
|
||||
Assert.assertEquals(promisedStreamId, frame.getPromisedStreamId());
|
||||
MetaData.Request request = (MetaData.Request)frame.getMetaData();
|
||||
Assert.assertSame(metaData.getScheme(), request.getScheme());
|
||||
Assert.assertEquals(metaData.getMethod(), request.getMethod());
|
||||
Assert.assertEquals(metaData.getHost(), request.getHost());
|
||||
Assert.assertEquals(metaData.getPort(), request.getPort());
|
||||
Assert.assertEquals(metaData.getURI(), request.getURI());
|
||||
for (int j = 0; j < fields.size(); ++j)
|
||||
{
|
||||
|
@ -119,7 +115,7 @@ public class PushPromiseGenerateParseTest
|
|||
HttpFields fields = new HttpFields();
|
||||
fields.put("Accept", "text/html");
|
||||
fields.put("User-Agent", "Jetty");
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, "GET", new HostPortHttpField("localhost:8080"), "/path", fields);
|
||||
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);
|
||||
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);
|
||||
|
@ -137,10 +133,7 @@ public class PushPromiseGenerateParseTest
|
|||
Assert.assertEquals(streamId, frame.getStreamId());
|
||||
Assert.assertEquals(promisedStreamId, frame.getPromisedStreamId());
|
||||
MetaData.Request request = (MetaData.Request)frame.getMetaData();
|
||||
Assert.assertSame(metaData.getScheme(), request.getScheme());
|
||||
Assert.assertEquals(metaData.getMethod(), request.getMethod());
|
||||
Assert.assertEquals(metaData.getHost(), request.getHost());
|
||||
Assert.assertEquals(metaData.getPort(), request.getPort());
|
||||
Assert.assertEquals(metaData.getURI(), request.getURI());
|
||||
for (int j = 0; j < fields.size(); ++j)
|
||||
{
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http2.hpack.HpackContext;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http2.hpack.HpackContext.Entry;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.EnumSet;
|
|||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.http2.hpack.HpackContext.Entry;
|
||||
|
@ -139,10 +140,11 @@ public class HpackEncoder
|
|||
MetaData.Request request = (MetaData.Request)metadata;
|
||||
|
||||
// TODO optimise these to avoid HttpField creation
|
||||
encode(buffer,new HttpField(":scheme",request.getScheme().asString()));
|
||||
String scheme=request.getURI().getScheme();
|
||||
encode(buffer,new HttpField(":scheme",scheme==null?HttpScheme.HTTP.asString():scheme));
|
||||
encode(buffer,new HttpField(":method",request.getMethod()));
|
||||
encode(buffer,new HttpField(":authority",request.getPort()>0?(request.getHost()+':'+request.getPort()):request.getHost()));
|
||||
encode(buffer,new HttpField(":path",request.getURI()));
|
||||
encode(buffer,new HttpField(":authority",request.getURI().getAuthority()));
|
||||
encode(buffer,new HttpField(":path",request.getURI().getPathQuery()));
|
||||
|
||||
}
|
||||
else if (metadata.isResponse())
|
||||
|
|
|
@ -21,13 +21,11 @@ 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;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
|
||||
|
@ -133,10 +131,10 @@ public class MetaDataBuilder
|
|||
HttpFields fields = _fields;
|
||||
_fields = new HttpFields(Math.max(10,fields.size()+5));
|
||||
if (_method!=null)
|
||||
return new FinalMetaData.Request(HttpVersion.HTTP_2,_scheme,_method,_authority,_path,fields);
|
||||
return new MetaData.Request(_method,_scheme,_authority,_path,HttpVersion.HTTP_2,fields);
|
||||
if (_status!=0)
|
||||
return new FinalMetaData.Response(HttpVersion.HTTP_2,_status,fields);
|
||||
return new FinalMetaData(HttpVersion.HTTP_2,fields);
|
||||
return new MetaData.Response(HttpVersion.HTTP_2,_status,fields);
|
||||
return new MetaData(HttpVersion.HTTP_2,fields);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -31,12 +37,6 @@ import org.hamcrest.Matchers;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
|
|
@ -19,20 +19,19 @@
|
|||
|
||||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -52,9 +51,9 @@ public class HpackDecoderTest
|
|||
MetaData.Request request = (MetaData.Request)decoder.decode(buffer);
|
||||
|
||||
assertEquals("GET", request.getMethod());
|
||||
assertEquals(HttpScheme.HTTP,request.getScheme());
|
||||
assertEquals("/",request.getURI());
|
||||
assertEquals("www.example.com",request.getHost());
|
||||
assertEquals(HttpScheme.HTTP.asString(),request.getURI().getScheme());
|
||||
assertEquals("/",request.getURI().getPath());
|
||||
assertEquals("www.example.com",request.getURI().getHost());
|
||||
assertFalse(request.iterator().hasNext());
|
||||
|
||||
|
||||
|
@ -65,9 +64,9 @@ public class HpackDecoderTest
|
|||
request = (MetaData.Request)decoder.decode(buffer);
|
||||
|
||||
assertEquals("GET", request.getMethod());
|
||||
assertEquals(HttpScheme.HTTP,request.getScheme());
|
||||
assertEquals("/",request.getURI());
|
||||
assertEquals("www.example.com",request.getHost());
|
||||
assertEquals(HttpScheme.HTTP.asString(),request.getURI().getScheme());
|
||||
assertEquals("/",request.getURI().getPath());
|
||||
assertEquals("www.example.com",request.getURI().getHost());
|
||||
Iterator<HttpField> iterator=request.iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
assertEquals(new HttpField("cache-control","no-cache"),iterator.next());
|
||||
|
@ -81,9 +80,9 @@ public class HpackDecoderTest
|
|||
request = (MetaData.Request)decoder.decode(buffer);
|
||||
|
||||
assertEquals("GET",request.getMethod());
|
||||
assertEquals(HttpScheme.HTTPS,request.getScheme());
|
||||
assertEquals("/index.html",request.getURI());
|
||||
assertEquals("www.example.com",request.getHost());
|
||||
assertEquals(HttpScheme.HTTPS.asString(),request.getURI().getScheme());
|
||||
assertEquals("/index.html",request.getURI().getPath());
|
||||
assertEquals("www.example.com",request.getURI().getHost());
|
||||
iterator=request.iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
assertEquals(new HttpField("custom-key","custom-value"),iterator.next());
|
||||
|
@ -102,9 +101,9 @@ public class HpackDecoderTest
|
|||
MetaData.Request request = (MetaData.Request)decoder.decode(buffer);
|
||||
|
||||
assertEquals("GET", request.getMethod());
|
||||
assertEquals(HttpScheme.HTTP,request.getScheme());
|
||||
assertEquals("/",request.getURI());
|
||||
assertEquals("www.example.com",request.getHost());
|
||||
assertEquals(HttpScheme.HTTP.asString(),request.getURI().getScheme());
|
||||
assertEquals("/",request.getURI().getPath());
|
||||
assertEquals("www.example.com",request.getURI().getHost());
|
||||
assertFalse(request.iterator().hasNext());
|
||||
|
||||
|
||||
|
@ -115,9 +114,9 @@ public class HpackDecoderTest
|
|||
request = (MetaData.Request)decoder.decode(buffer);
|
||||
|
||||
assertEquals("GET", request.getMethod());
|
||||
assertEquals(HttpScheme.HTTP,request.getScheme());
|
||||
assertEquals("/",request.getURI());
|
||||
assertEquals("www.example.com",request.getHost());
|
||||
assertEquals(HttpScheme.HTTP.asString(),request.getURI().getScheme());
|
||||
assertEquals("/",request.getURI().getPath());
|
||||
assertEquals("www.example.com",request.getURI().getHost());
|
||||
Iterator<HttpField> iterator=request.iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
assertEquals(new HttpField("cache-control","no-cache"),iterator.next());
|
||||
|
@ -130,9 +129,9 @@ public class HpackDecoderTest
|
|||
request = (MetaData.Request)decoder.decode(buffer);
|
||||
|
||||
assertEquals("GET",request.getMethod());
|
||||
assertEquals(HttpScheme.HTTPS,request.getScheme());
|
||||
assertEquals("/index.html",request.getURI());
|
||||
assertEquals("www.example.com",request.getHost());
|
||||
assertEquals(HttpScheme.HTTPS.asString(),request.getURI().getScheme());
|
||||
assertEquals("/index.html",request.getURI().getPath());
|
||||
assertEquals("www.example.com",request.getURI().getHost());
|
||||
iterator=request.iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
assertEquals(new HttpField("custom-key","custom-value"),iterator.next());
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
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;
|
||||
|
@ -34,8 +35,6 @@ import org.hamcrest.Matchers;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -71,7 +70,7 @@ public class HpackEncoderTest
|
|||
// encode them
|
||||
ByteBuffer buffer = BufferUtil.allocate(4096);
|
||||
int pos = BufferUtil.flipToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,pos);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -90,7 +89,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode exact same fields again!
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// nothing should be encoded!
|
||||
|
@ -113,7 +112,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -137,7 +136,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -164,7 +163,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -192,7 +191,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -226,7 +225,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -247,7 +246,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
@ -259,7 +258,7 @@ public class HpackEncoderTest
|
|||
|
||||
// encode again
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,new FinalMetaData(HttpVersion.HTTP_2,fields));
|
||||
encoder.encode(buffer,new MetaData(HttpVersion.HTTP_2,fields));
|
||||
BufferUtil.flipToFlush(buffer,0);
|
||||
|
||||
// something was encoded!
|
||||
|
|
|
@ -24,7 +24,6 @@ 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;
|
||||
|
@ -51,7 +50,7 @@ public class HpackTest
|
|||
fields0.add(HttpHeader.SERVER,"jetty");
|
||||
fields0.add(HttpHeader.SET_COOKIE,"abcdefghijklmnopqrstuvwxyz");
|
||||
fields0.add("custom-key","custom-value");
|
||||
Response original0 = new FinalMetaData.Response(HttpVersion.HTTP_2,200,fields0);
|
||||
Response original0 = new MetaData.Response(HttpVersion.HTTP_2,200,fields0);
|
||||
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,original0);
|
||||
|
@ -73,7 +72,7 @@ public class HpackTest
|
|||
fields1.add(HttpHeader.CONTENT_LENGTH,"1234");
|
||||
fields1.add(HttpHeader.SERVER,"jetty");
|
||||
fields1.add("Custom-Key","Other-Value");
|
||||
Response original1 = new FinalMetaData.Response(HttpVersion.HTTP_2,200,fields1);
|
||||
Response original1 = new MetaData.Response(HttpVersion.HTTP_2,200,fields1);
|
||||
|
||||
// Same again?
|
||||
BufferUtil.clearToFill(buffer);
|
||||
|
@ -97,7 +96,7 @@ public class HpackTest
|
|||
HttpFields fields0 = new HttpFields();
|
||||
fields0.add("1234567890","1234567890123456789012345678901234567890");
|
||||
fields0.add("Cookie","abcdeffhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR");
|
||||
MetaData original0= new FinalMetaData(HttpVersion.HTTP_2,fields0);
|
||||
MetaData original0= new MetaData(HttpVersion.HTTP_2,fields0);
|
||||
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,original0);
|
||||
|
@ -110,7 +109,7 @@ public class HpackTest
|
|||
fields1.add("1234567890","1234567890123456789012345678901234567890");
|
||||
fields1.add("Cookie","abcdeffhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR");
|
||||
fields1.add("x","y");
|
||||
MetaData original1 = new FinalMetaData(HttpVersion.HTTP_2,fields1);
|
||||
MetaData original1 = new MetaData(HttpVersion.HTTP_2,fields1);
|
||||
|
||||
BufferUtil.clearToFill(buffer);
|
||||
encoder.encode(buffer,original1);
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.http2.hpack;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
@ -25,8 +27,6 @@ import org.eclipse.jetty.util.TypeUtil;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class NBitIntegerTest
|
||||
{
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class HttpChannelOverHTTP2 extends HttpChannel
|
|||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("HTTP2 Request #{}:{}{} {} {}{}{}",
|
||||
stream.getId(), System.lineSeparator(), request.getMethod(), request.getURI(), request.getHttpVersion(), System.lineSeparator(), fields);
|
||||
stream.getId(), System.lineSeparator(), request.getMethod(), request.getURI(), request.getVersion(), System.lineSeparator(), fields);
|
||||
}
|
||||
|
||||
execute(this);
|
||||
|
|
|
@ -21,7 +21,6 @@ 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;
|
||||
|
@ -82,7 +81,7 @@ public class HttpTransportOverHTTP2 implements HttpTransport
|
|||
System.lineSeparator(), info.getHttpFields());
|
||||
}
|
||||
|
||||
MetaData metaData = new FinalMetaData.Response(HttpVersion.HTTP_2, info.getStatus(), info.getHttpFields());
|
||||
MetaData metaData = new MetaData.Response(HttpVersion.HTTP_2, info.getStatus(), info.getHttpFields());
|
||||
HeadersFrame frame = new HeadersFrame(stream.getId(), metaData, null, endStream);
|
||||
stream.headers(frame, callback);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ 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;
|
||||
|
@ -100,8 +99,8 @@ public class HTTP2ServerTest
|
|||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
new HostPortHttpField(host + ":" + port), path, fields);
|
||||
MetaData.Request metaData = new MetaData.Request(HttpMethod.GET.asString(), HttpScheme.HTTP, new HostPortHttpField(host + ":" + port),
|
||||
path, HttpVersion.HTTP_2, fields);
|
||||
HeadersFrame request = new HeadersFrame(1, metaData, null, true);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.control(lease, request);
|
||||
|
@ -149,8 +148,8 @@ public class HTTP2ServerTest
|
|||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2, HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
new HostPortHttpField(host + ":" + port), path, fields);
|
||||
MetaData.Request metaData = new MetaData.Request(HttpMethod.GET.asString(), HttpScheme.HTTP, new HostPortHttpField(host + ":" + port),
|
||||
path, HttpVersion.HTTP_2, fields);
|
||||
HeadersFrame request = new HeadersFrame(1, metaData, null, true);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.control(lease, request);
|
||||
|
@ -212,8 +211,8 @@ public class HTTP2ServerTest
|
|||
String host = "localhost";
|
||||
int port = connector.getLocalPort();
|
||||
HttpFields fields = new HttpFields();
|
||||
MetaData.Request metaData = new FinalMetaData.Request(HttpVersion.HTTP_2,HttpScheme.HTTP, HttpMethod.GET.asString(),
|
||||
new HostPortHttpField(host + ":" + port), path, fields);
|
||||
MetaData.Request metaData = new MetaData.Request(HttpMethod.GET.asString(),HttpScheme.HTTP, new HostPortHttpField(host + ":" + port),
|
||||
path, HttpVersion.HTTP_2, fields);
|
||||
HeadersFrame request = new HeadersFrame(1, metaData, null, true);
|
||||
ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
|
||||
generator.control(lease, request);
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
|
@ -46,7 +47,7 @@ import org.eclipse.jetty.server.HttpConfiguration.Customizer;
|
|||
*/
|
||||
public class ForwardedRequestCustomizer implements Customizer
|
||||
{
|
||||
private String _hostHeader;
|
||||
private HostPortHttpField _hostHeader;
|
||||
private String _forwardedHostHeader = HttpHeader.X_FORWARDED_HOST.toString();
|
||||
private String _forwardedServerHeader = HttpHeader.X_FORWARDED_SERVER.toString();
|
||||
private String _forwardedForHeader = HttpHeader.X_FORWARDED_FOR.toString();
|
||||
|
@ -58,7 +59,7 @@ public class ForwardedRequestCustomizer implements Customizer
|
|||
/* ------------------------------------------------------------ */
|
||||
public String getHostHeader()
|
||||
{
|
||||
return _hostHeader;
|
||||
return _hostHeader.getValue();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -70,7 +71,7 @@ public class ForwardedRequestCustomizer implements Customizer
|
|||
*/
|
||||
public void setHostHeader(String hostHeader)
|
||||
{
|
||||
_hostHeader = hostHeader;
|
||||
_hostHeader = new HostPortHttpField(hostHeader);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -224,18 +225,17 @@ public class ForwardedRequestCustomizer implements Customizer
|
|||
if (_hostHeader != null)
|
||||
{
|
||||
// Update host header
|
||||
httpFields.put(HttpHeader.HOST.toString(),_hostHeader);
|
||||
request.setServerName(null);
|
||||
request.setServerPort(-1);
|
||||
request.getServerName();
|
||||
httpFields.put(_hostHeader);
|
||||
request.setServerName(_hostHeader.getHost());
|
||||
request.setServerPort(_hostHeader.getPort());
|
||||
}
|
||||
else if (forwardedHost != null)
|
||||
{
|
||||
// Update host header
|
||||
httpFields.put(HttpHeader.HOST.toString(),forwardedHost);
|
||||
request.setServerName(null);
|
||||
request.setServerPort(-1);
|
||||
request.getServerName();
|
||||
HostPortHttpField auth = new HostPortHttpField(forwardedHost);
|
||||
httpFields.put(auth);
|
||||
request.setServerName(auth.getHost());
|
||||
request.setServerPort(auth.getPort());
|
||||
}
|
||||
else if (forwardedServer != null)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.IOException;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.AbstractMetaData;
|
||||
import org.eclipse.jetty.http.HostPortHttpField;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
|
@ -34,9 +33,11 @@ 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;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.omg.stub.java.rmi._Remote_Stub;
|
||||
|
||||
/**
|
||||
* A HttpChannel customized to be transported over the HTTP/1 protocol
|
||||
|
@ -44,64 +45,22 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandler, HttpParser.ProxyHandler
|
||||
{
|
||||
private final HttpConnection _httpConnection;
|
||||
private String _method;
|
||||
private String _uri;
|
||||
private HttpVersion _version;
|
||||
private final HttpFields _fields = new HttpFields();
|
||||
private HostPortHttpField _hostPort;
|
||||
private HttpField _connection;
|
||||
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()
|
||||
{
|
||||
return HttpScheme.HTTP;
|
||||
}
|
||||
private final HttpURI _uri = new HttpURI();
|
||||
private final MetaData.Request _metadata = new MetaData.Request();
|
||||
|
||||
@Override
|
||||
public String getHost()
|
||||
{
|
||||
return _hostPort==null?null:_hostPort.getHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort()
|
||||
{
|
||||
return _hostPort==null?0:_hostPort.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String 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)
|
||||
{
|
||||
super(connector,config,endPoint,transport,input);
|
||||
_httpConnection = httpConnection;
|
||||
_metadata.setFields(_fields);
|
||||
_metadata.setURI(_uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,10 +70,7 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
_expect = false;
|
||||
_expect100Continue = false;
|
||||
_expect102Processing = false;
|
||||
_method=null;
|
||||
_uri=null;
|
||||
_version=null;
|
||||
_hostPort=null;
|
||||
_uri.clear();
|
||||
_connection=null;
|
||||
_fields.clear();
|
||||
}
|
||||
|
@ -134,9 +90,9 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
@Override
|
||||
public boolean startRequest(String method, String uri, HttpVersion version)
|
||||
{
|
||||
_method=method;
|
||||
_uri=uri;
|
||||
_version=version;
|
||||
_metadata.setMethod(method);
|
||||
_uri.parse(uri);
|
||||
_metadata.setHttpVersion(version);
|
||||
_expect = false;
|
||||
_expect100Continue = false;
|
||||
_expect102Processing = false;
|
||||
|
@ -146,7 +102,7 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
@Override
|
||||
public void proxied(String protocol, String sAddr, String dAddr, int sPort, int dPort)
|
||||
{
|
||||
_method=HttpMethod.CONNECT.asString();
|
||||
_metadata.setMethod(HttpMethod.CONNECT.asString());
|
||||
Request request = getRequest();
|
||||
request.setAttribute("PROXY", protocol);
|
||||
request.setServerName(sAddr);
|
||||
|
@ -168,12 +124,16 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
break;
|
||||
|
||||
case HOST:
|
||||
_hostPort=(HostPortHttpField)field;
|
||||
if (!_uri.isAbsolute() && field instanceof HostPortHttpField)
|
||||
{
|
||||
HostPortHttpField hp = (HostPortHttpField)field;
|
||||
_uri.setAuth(hp.getHost(),hp.getPort());
|
||||
}
|
||||
break;
|
||||
|
||||
case EXPECT:
|
||||
{
|
||||
if (_version==HttpVersion.HTTP_1_1)
|
||||
if (_metadata.getVersion()==HttpVersion.HTTP_1_1)
|
||||
{
|
||||
HttpHeaderValue expect = HttpHeaderValue.CACHE.get(value);
|
||||
switch (expect == null ? HttpHeaderValue.UNKNOWN : expect)
|
||||
|
@ -253,7 +213,7 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
public void earlyEOF()
|
||||
{
|
||||
// If we have no request yet, just close
|
||||
if (_method==null)
|
||||
if (_metadata.getMethod()==null)
|
||||
_httpConnection.close();
|
||||
else
|
||||
onEarlyEOF();
|
||||
|
@ -279,7 +239,7 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
{
|
||||
boolean persistent;
|
||||
|
||||
switch (_version)
|
||||
switch (_metadata.getVersion())
|
||||
{
|
||||
case HTTP_1_0:
|
||||
{
|
||||
|
@ -294,7 +254,7 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
persistent=false;
|
||||
|
||||
if (!persistent)
|
||||
persistent = HttpMethod.CONNECT.is(_method);
|
||||
persistent = HttpMethod.CONNECT.is(_metadata.getMethod());
|
||||
if (persistent)
|
||||
getResponse().getHttpFields().add(HttpHeader.CONNECTION, HttpHeaderValue.KEEP_ALIVE);
|
||||
|
||||
|
@ -320,7 +280,7 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
persistent=true;
|
||||
|
||||
if (!persistent)
|
||||
persistent = HttpMethod.CONNECT.is(_method);
|
||||
persistent = HttpMethod.CONNECT.is(_metadata.getMethod());
|
||||
if (!persistent)
|
||||
getResponse().getHttpFields().add(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE);
|
||||
break;
|
||||
|
|
|
@ -922,7 +922,7 @@ public class Request implements HttpServletRequest
|
|||
@Override
|
||||
public String getProtocol()
|
||||
{
|
||||
return _metadata==null?null:_metadata.getHttpVersion().toString();
|
||||
return _metadata==null?null:_metadata.getVersion().toString();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -931,7 +931,7 @@ public class Request implements HttpServletRequest
|
|||
*/
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return _metadata==null?null:_metadata.getHttpVersion();
|
||||
return _metadata==null?null:_metadata.getVersion();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -1117,7 +1117,7 @@ public class Request implements HttpServletRequest
|
|||
public String getRequestURI()
|
||||
{
|
||||
if (_requestURI == null && _uri != null)
|
||||
_requestURI = _uri.getPathAndParam();
|
||||
_requestURI = _uri.getPath();
|
||||
return _requestURI;
|
||||
}
|
||||
|
||||
|
@ -1537,9 +1537,11 @@ public class Request implements HttpServletRequest
|
|||
{
|
||||
_metadata=request;
|
||||
setMethod(request.getMethod());
|
||||
setScheme(request.getScheme().asString());
|
||||
HttpURI uri = request.getURI();
|
||||
|
||||
HttpURI uri = new HttpURI(request.getURI());
|
||||
String scheme=uri.getScheme();
|
||||
if (scheme!=null)
|
||||
setScheme(scheme);
|
||||
|
||||
String uriHost=uri.getHost();
|
||||
if (uriHost!=null)
|
||||
|
@ -1548,29 +1550,32 @@ public class Request implements HttpServletRequest
|
|||
setServerName(uriHost);
|
||||
setServerPort(uri.getPort());
|
||||
}
|
||||
else
|
||||
{
|
||||
setServerName(request.getHost());
|
||||
setServerPort(request.getPort());
|
||||
}
|
||||
|
||||
setUri(uri);
|
||||
|
||||
|
||||
String path = uri.getDecodedPath();
|
||||
|
||||
String info = URIUtil.canonicalPath(path); // TODO should this be done prior to decoding???
|
||||
|
||||
if (info == null)
|
||||
String info;
|
||||
if (path==null || path.length()==0)
|
||||
{
|
||||
if( path==null && uri.getScheme()!=null && uri.getHost()!=null)
|
||||
{
|
||||
info = "/";
|
||||
setRequestURI("");
|
||||
}
|
||||
if (uri.isAbsolute())
|
||||
path="/";
|
||||
else
|
||||
throw new BadMessageException(400,"Bad URI");
|
||||
info=path;
|
||||
}
|
||||
else if (!path.startsWith("/"))
|
||||
{
|
||||
if (!"*".equals(path) && !HttpMethod.CONNECT.is(getMethod()))
|
||||
throw new BadMessageException(400,"Bad URI");
|
||||
info=path;
|
||||
}
|
||||
else
|
||||
info = URIUtil.canonicalPath(path);// TODO should this be done prior to decoding???
|
||||
|
||||
if (info == null)
|
||||
throw new BadMessageException(400,"Bad URI");
|
||||
|
||||
setPathInfo(info);
|
||||
}
|
||||
|
||||
|
@ -2010,7 +2015,6 @@ 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;
|
||||
|
|
|
@ -20,13 +20,11 @@ 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;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MetaData;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
|
@ -164,7 +162,7 @@ public class HttpChannelOverSPDY extends HttpChannel
|
|||
// At last, add the Host header.
|
||||
fields.add(hostPort);
|
||||
|
||||
MetaData.Request request = new FinalMetaData.Request(httpVersion, HttpScheme.HTTP.asString(), httpMethod==null?methodHeader.getValue():httpMethod.asString(), uriHeader.getValue(), fields, hostPort);
|
||||
MetaData.Request request = new MetaData.Request(httpMethod==null?methodHeader.getValue():httpMethod.asString(), HttpScheme.HTTP.asString(), hostPort, uriHeader.getValue(), httpVersion, fields);
|
||||
onRequest(request);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.http;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -27,6 +31,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -63,10 +68,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class ReferrerPushStrategyTest extends AbstractHTTPSPDYTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ReferrerPushStrategyTest.class);
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
@ -62,9 +65,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class ProxyHTTPToSPDYTest
|
||||
{
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -33,6 +38,7 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -71,11 +77,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@Ignore
|
||||
@RunWith(value = Parameterized.class)
|
||||
public abstract class ProxySPDYToHTTPLoadTest
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -27,6 +32,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -69,11 +75,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(value = Parameterized.class)
|
||||
public abstract class ProxySPDYToHTTPTest
|
||||
{
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
|
@ -60,10 +64,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(value = Parameterized.class)
|
||||
public abstract class ProxySPDYToSPDYLoadTest
|
||||
{
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.spdy.server.proxy;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -62,9 +65,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(value = Parameterized.class)
|
||||
public abstract class ProxySPDYToSPDYTest
|
||||
{
|
||||
|
|
|
@ -781,6 +781,16 @@ public class UrlEncoded extends MultiMap<String> implements Cloneable
|
|||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/** Decode String with % encoding.
|
||||
* This method makes the assumption that the majority of calls
|
||||
* will need no decoding.
|
||||
*/
|
||||
public static String decodeString(String encoded)
|
||||
{
|
||||
return decodeString(encoded,0,encoded.length(),ENCODING);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/** Decode String with % encoding.
|
||||
* This method makes the assumption that the majority of calls
|
||||
|
|
Loading…
Reference in New Issue