mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-03 04:19:12 +00:00
Merged branch 'master' into 'jetty-9.1'.
This commit is contained in:
commit
f4a41efaad
@ -91,7 +91,7 @@ public abstract class HttpConnection implements Connection
|
|||||||
if (request.getIdleTimeout() <= 0)
|
if (request.getIdleTimeout() <= 0)
|
||||||
request.idleTimeout(client.getIdleTimeout(), TimeUnit.MILLISECONDS);
|
request.idleTimeout(client.getIdleTimeout(), TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
HttpMethod method = request.getMethod();
|
String method = request.getMethod();
|
||||||
HttpVersion version = request.getVersion();
|
HttpVersion version = request.getVersion();
|
||||||
HttpFields headers = request.getHeaders();
|
HttpFields headers = request.getHeaders();
|
||||||
ContentProvider content = request.getContent();
|
ContentProvider content = request.getContent();
|
||||||
@ -106,7 +106,7 @@ public abstract class HttpConnection implements Connection
|
|||||||
path = "/";
|
path = "/";
|
||||||
request.path(path);
|
request.path(path);
|
||||||
}
|
}
|
||||||
if (destination.isProxied() && HttpMethod.CONNECT != method)
|
if (destination.isProxied() && !HttpMethod.CONNECT.is(method))
|
||||||
{
|
{
|
||||||
path = request.getURI().toString();
|
path = request.getURI().toString();
|
||||||
request.path(path);
|
request.path(path);
|
||||||
|
@ -29,6 +29,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@ -65,7 +66,7 @@ public class HttpRequest implements Request
|
|||||||
private String scheme;
|
private String scheme;
|
||||||
private String path;
|
private String path;
|
||||||
private String query;
|
private String query;
|
||||||
private HttpMethod method;
|
private String method;
|
||||||
private HttpVersion version;
|
private HttpVersion version;
|
||||||
private long idleTimeout;
|
private long idleTimeout;
|
||||||
private long timeout;
|
private long timeout;
|
||||||
@ -125,7 +126,7 @@ public class HttpRequest implements Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpMethod getMethod()
|
public String getMethod()
|
||||||
{
|
{
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
@ -133,7 +134,14 @@ public class HttpRequest implements Request
|
|||||||
@Override
|
@Override
|
||||||
public Request method(HttpMethod method)
|
public Request method(HttpMethod method)
|
||||||
{
|
{
|
||||||
this.method = method;
|
this.method = method.asString();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request method(String method)
|
||||||
|
{
|
||||||
|
this.method = Objects.requireNonNull(method).toUpperCase(Locale.ENGLISH);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +95,9 @@ public class RedirectProtocolHandler extends Response.Listener.Empty implements
|
|||||||
{
|
{
|
||||||
case 301:
|
case 301:
|
||||||
{
|
{
|
||||||
if (request.getMethod() == HttpMethod.GET || request.getMethod() == HttpMethod.HEAD)
|
String method = request.getMethod();
|
||||||
redirect(result, request.getMethod(), newURI);
|
if (HttpMethod.GET.is(method) || HttpMethod.HEAD.is(method))
|
||||||
|
redirect(result, method, newURI);
|
||||||
else
|
else
|
||||||
fail(result, new HttpResponseException("HTTP protocol violation: received 301 for non GET or HEAD request", response));
|
fail(result, new HttpResponseException("HTTP protocol violation: received 301 for non GET or HEAD request", response));
|
||||||
break;
|
break;
|
||||||
@ -105,7 +106,7 @@ public class RedirectProtocolHandler extends Response.Listener.Empty implements
|
|||||||
case 303:
|
case 303:
|
||||||
{
|
{
|
||||||
// Redirect must be done using GET
|
// Redirect must be done using GET
|
||||||
redirect(result, HttpMethod.GET, newURI);
|
redirect(result, HttpMethod.GET.asString(), newURI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 307:
|
case 307:
|
||||||
@ -174,7 +175,7 @@ public class RedirectProtocolHandler extends Response.Listener.Empty implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void redirect(Result result, HttpMethod method, URI location)
|
private void redirect(Result result, String method, URI location)
|
||||||
{
|
{
|
||||||
final Request request = result.getRequest();
|
final Request request = result.getRequest();
|
||||||
HttpConversation conversation = client.getConversation(request.getConversationID(), false);
|
HttpConversation conversation = client.getConversation(request.getConversationID(), false);
|
||||||
|
@ -76,9 +76,9 @@ public interface Request
|
|||||||
int getPort();
|
int getPort();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the method of this request, such as GET or POST
|
* @return the method of this request, such as GET or POST, as a String
|
||||||
*/
|
*/
|
||||||
HttpMethod getMethod();
|
String getMethod();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param method the method of this request, such as GET or POST
|
* @param method the method of this request, such as GET or POST
|
||||||
@ -86,6 +86,12 @@ public interface Request
|
|||||||
*/
|
*/
|
||||||
Request method(HttpMethod method);
|
Request method(HttpMethod method);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param method the method of this request, such as GET or POST
|
||||||
|
* @return this request object
|
||||||
|
*/
|
||||||
|
Request method(String method);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the path of this request, such as "/" or "/path" - without the query
|
* @return the path of this request, such as "/" or "/path" - without the query
|
||||||
* @see #getQuery()
|
* @see #getQuery()
|
||||||
|
@ -132,7 +132,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
|
|||||||
if (exchange == null)
|
if (exchange == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
parser.setHeadResponse(exchange.getRequest().getMethod() == HttpMethod.HEAD);
|
parser.setHeadResponse(HttpMethod.HEAD.is(exchange.getRequest().getMethod()));
|
||||||
exchange.getResponse().version(version).status(status).reason(reason);
|
exchange.getResponse().version(version).status(status).reason(reason);
|
||||||
|
|
||||||
responseBegin(exchange);
|
responseBegin(exchange);
|
||||||
|
@ -56,7 +56,7 @@ public class HttpSenderOverHTTP extends HttpSender
|
|||||||
String query = request.getQuery();
|
String query = request.getQuery();
|
||||||
if (query != null)
|
if (query != null)
|
||||||
path += "?" + query;
|
path += "?" + query;
|
||||||
HttpGenerator.RequestInfo requestInfo = new HttpGenerator.RequestInfo(request.getVersion(), request.getHeaders(), contentLength, request.getMethod().asString(), path);
|
HttpGenerator.RequestInfo requestInfo = new HttpGenerator.RequestInfo(request.getVersion(), request.getHeaders(), contentLength, request.getMethod(), path);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@ public class DigestAuthentication implements Authentication
|
|||||||
String A1 = user + ":" + realm + ":" + password;
|
String A1 = user + ":" + realm + ":" + password;
|
||||||
String hashA1 = toHexString(digester.digest(A1.getBytes(charset)));
|
String hashA1 = toHexString(digester.digest(A1.getBytes(charset)));
|
||||||
|
|
||||||
String A2 = request.getMethod().asString() + ":" + request.getURI();
|
String A2 = request.getMethod() + ":" + request.getURI();
|
||||||
if ("auth-int".equals(qop))
|
if ("auth-int".equals(qop))
|
||||||
A2 += ":" + toHexString(digester.digest(content));
|
A2 += ":" + toHexString(digester.digest(content));
|
||||||
String hashA2 = toHexString(digester.digest(A2.getBytes(charset)));
|
String hashA2 = toHexString(digester.digest(A2.getBytes(charset)));
|
||||||
|
@ -117,7 +117,7 @@ public enum HttpMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public final static Trie<HttpMethod> CACHE= new ArrayTrie<HttpMethod>();
|
public final static Trie<HttpMethod> CACHE= new ArrayTrie<>();
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
for (HttpMethod method : HttpMethod.values())
|
for (HttpMethod method : HttpMethod.values())
|
||||||
|
@ -65,7 +65,7 @@ public class HttpSenderOverSPDY extends HttpSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add special SPDY headers
|
// Add special SPDY headers
|
||||||
fields.put(HTTPSPDYHeader.METHOD.name(spdyVersion), request.getMethod().asString());
|
fields.put(HTTPSPDYHeader.METHOD.name(spdyVersion), request.getMethod());
|
||||||
String path = request.getPath();
|
String path = request.getPath();
|
||||||
String query = request.getQuery();
|
String query = request.getQuery();
|
||||||
if (query != null)
|
if (query != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user