* Cleanup of relative redirect handling #11014 + Handle request relative redirects + Moved to Response + Changed default to allow relative * Updates to javadoc
This commit is contained in:
parent
ce80691d1d
commit
71354331e5
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
|
@ -88,7 +87,7 @@ public class RedirectPatternRule extends PatternRule
|
|||
{
|
||||
String location = getLocation();
|
||||
response.setStatus(getStatusCode());
|
||||
response.getHeaders().put(HttpHeader.LOCATION, Request.toRedirectURI(this, location));
|
||||
response.getHeaders().put(HttpHeader.LOCATION, Response.toRedirectURI(this, location));
|
||||
callback.succeeded();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.regex.Matcher;
|
|||
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
|
@ -86,7 +85,7 @@ public class RedirectRegexRule extends RegexRule
|
|||
{
|
||||
String target = matcher.replaceAll(getLocation());
|
||||
response.setStatus(_statusCode);
|
||||
response.getHeaders().put(HttpHeader.LOCATION, Request.toRedirectURI(this, target));
|
||||
response.getHeaders().put(HttpHeader.LOCATION, Response.toRedirectURI(this, target));
|
||||
callback.succeeded();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class RedirectRegexRuleTest extends AbstractRuleTest
|
|||
|
||||
HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
|
||||
assertEquals(HttpStatus.FOUND_302, response.getStatus());
|
||||
assertEquals("http://localhost/docs/top.html", response.get(HttpHeader.LOCATION));
|
||||
assertEquals("/docs/top.html", response.get(HttpHeader.LOCATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -277,7 +277,9 @@ public class FormAuthenticator extends LoginAuthenticator
|
|||
// Redirect to original request
|
||||
Session session = request.getSession(false);
|
||||
HttpURI savedURI = (HttpURI)session.getAttribute(__J_URI);
|
||||
String originalURI = savedURI != null ? savedURI.asString() : Request.getContextPath(request);
|
||||
String originalURI = savedURI != null
|
||||
? savedURI.getPathQuery()
|
||||
: Request.getContextPath(request);
|
||||
if (originalURI == null)
|
||||
originalURI = "/";
|
||||
UserAuthenticationSent formAuth = new UserAuthenticationSent(getAuthenticationType(), user);
|
||||
|
|
|
@ -129,17 +129,17 @@ public class FormAuthenticatorTest
|
|||
|
||||
response = _connector.getResponse("GET /ctx/any/user HTTP/1.0\r\nHost:host:8888\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
|
||||
response = _connector.getResponse("GET /ctx/known/user HTTP/1.0\r\nHost:host:8888\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
|
||||
response = _connector.getResponse("GET /ctx/admin/user HTTP/1.0\r\nHost:host:8888\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ public class FormAuthenticatorTest
|
|||
|
||||
response = _connector.getResponse("GET /ctx/any/user HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + sessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, not(containsString("Set-Cookie: JSESSIONID=")));
|
||||
}
|
||||
|
||||
|
@ -182,13 +182,13 @@ public class FormAuthenticatorTest
|
|||
String sessionId = "unknown";
|
||||
response = _connector.getResponse("GET /ctx/any/user HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + sessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
sessionId = sessionId(response);
|
||||
|
||||
response = _connector.getResponse("GET /ctx/j_security_check?j_username=user&j_password=wrong HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + sessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/error"));
|
||||
assertThat(response, containsString("Location: /ctx/error"));
|
||||
assertThat(response, not(containsString("Set-Cookie: JSESSIONID=")));
|
||||
|
||||
response = _connector.getResponse("""
|
||||
|
@ -201,7 +201,7 @@ public class FormAuthenticatorTest
|
|||
j_username=user&j_password=wrong
|
||||
""");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/error"));
|
||||
assertThat(response, containsString("Location: /ctx/error"));
|
||||
assertThat(response, not(containsString("Set-Cookie: JSESSIONID=")));
|
||||
}
|
||||
|
||||
|
@ -216,13 +216,13 @@ public class FormAuthenticatorTest
|
|||
String sessionId = "unknown";
|
||||
response = _connector.getResponse("GET /ctx/any/user HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + sessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
sessionId = sessionId(response);
|
||||
|
||||
response = _connector.getResponse("GET /ctx/j_security_check?j_username=user&j_password=password HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + sessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/any/user"));
|
||||
assertThat(response, containsString("Location: /ctx/any/user"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
String unsafeSessionId = sessionId;
|
||||
sessionId = sessionId(response);
|
||||
|
@ -240,7 +240,7 @@ public class FormAuthenticatorTest
|
|||
|
||||
response = _connector.getResponse("GET /ctx/any/user HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + unsafeSessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ public class FormAuthenticatorTest
|
|||
String sessionId = "unknown";
|
||||
response = _connector.getResponse("GET /ctx/any/user HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + sessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
sessionId = sessionId(response);
|
||||
|
||||
|
@ -269,7 +269,7 @@ public class FormAuthenticatorTest
|
|||
j_username=user&j_password=password
|
||||
""".formatted(sessionId));
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/any/user"));
|
||||
assertThat(response, containsString("Location: /ctx/any/user"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
String unsafeSessionId = sessionId;
|
||||
sessionId = sessionId(response);
|
||||
|
@ -287,7 +287,7 @@ public class FormAuthenticatorTest
|
|||
|
||||
response = _connector.getResponse("GET /ctx/any/user HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + unsafeSessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
}
|
||||
|
||||
|
@ -311,13 +311,13 @@ public class FormAuthenticatorTest
|
|||
name1=value1&name2=value2\r
|
||||
""".formatted(sessionId));
|
||||
assertThat(response, containsString("HTTP/1.1 303 See Other"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/login"));
|
||||
assertThat(response, containsString("Location: /ctx/login"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
sessionId = sessionId(response);
|
||||
|
||||
response = _connector.getResponse("GET /ctx/j_security_check?j_username=user&j_password=password HTTP/1.0\r\nHost:host:8888\r\nCookie: JSESSIONID=" + sessionId + "\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: http://host:8888/ctx/any/user?action=form"));
|
||||
assertThat(response, containsString("Location: /ctx/any/user?action=form"));
|
||||
assertThat(response, containsString("Set-Cookie: JSESSIONID="));
|
||||
String unsafeSessionId = sessionId;
|
||||
sessionId = sessionId(response);
|
||||
|
|
|
@ -63,7 +63,7 @@ etc/jetty.xml
|
|||
# jetty.httpConfig.maxErrorDispatches=10
|
||||
|
||||
## Relative Redirect Locations allowed
|
||||
# jetty.httpConfig.relativeRedirectAllowed=false
|
||||
# jetty.httpConfig.relativeRedirectAllowed=true
|
||||
|
||||
## Whether to use direct ByteBuffers for reading or writing
|
||||
# jetty.httpConfig.useInputDirectByteBuffers=true
|
||||
|
|
|
@ -76,7 +76,7 @@ public class HttpConfiguration implements Dumpable
|
|||
private CookieCompliance _requestCookieCompliance = CookieCompliance.RFC6265;
|
||||
private CookieCompliance _responseCookieCompliance = CookieCompliance.RFC6265;
|
||||
private boolean _notifyRemoteAsyncErrors = true;
|
||||
private boolean _relativeRedirectAllowed;
|
||||
private boolean _relativeRedirectAllowed = true;
|
||||
private HostPort _serverAuthority;
|
||||
private SocketAddress _localAddress;
|
||||
private int _maxUnconsumedRequestContentReads = 16;
|
||||
|
|
|
@ -604,45 +604,18 @@ public interface Request extends Attributes, Content.Source
|
|||
}
|
||||
|
||||
/**
|
||||
* Common point to generate a proper "Location" header for redirects.
|
||||
* Generate a proper "Location" header for redirects.
|
||||
*
|
||||
* @param request the request the redirect should be based on (needed when relative locations are provided, so that
|
||||
* server name, scheme, port can be built out properly)
|
||||
* @param location the location URL to redirect to (can be a relative path)
|
||||
* @return the full redirect "Location" URL (including scheme, host, port, path, etc...)
|
||||
* @deprecated use {@link Response#toRedirectURI(Request, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
static String toRedirectURI(Request request, String location)
|
||||
{
|
||||
if (!URIUtil.hasScheme(location) && !request.getConnectionMetaData().getHttpConfiguration().isRelativeRedirectAllowed())
|
||||
{
|
||||
StringBuilder url = new StringBuilder(128);
|
||||
HttpURI uri = request.getHttpURI();
|
||||
URIUtil.appendSchemeHostPort(url, uri.getScheme(), Request.getServerName(request), Request.getServerPort(request));
|
||||
|
||||
if (location.startsWith("/"))
|
||||
{
|
||||
// absolute in context
|
||||
location = URIUtil.normalizePathQuery(location);
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative to request
|
||||
String path = uri.getPath();
|
||||
String parent = (path.endsWith("/")) ? path : URIUtil.parentPath(path);
|
||||
location = URIUtil.normalizePathQuery(URIUtil.addEncodedPaths(parent, location));
|
||||
if (location != null && !location.startsWith("/"))
|
||||
url.append('/');
|
||||
}
|
||||
|
||||
if (location == null)
|
||||
throw new IllegalStateException("redirect path cannot be above root");
|
||||
url.append(location);
|
||||
|
||||
location = url.toString();
|
||||
}
|
||||
// TODO do we need to do request relative without scheme?
|
||||
|
||||
return location;
|
||||
return Response.toRedirectURI(request, location);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.Trailers;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
|
@ -38,6 +39,7 @@ import org.eclipse.jetty.server.handler.ErrorHandler;
|
|||
import org.eclipse.jetty.server.internal.HttpChannelState;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -238,7 +240,7 @@ public interface Response extends Content.Sink
|
|||
* @param request the HTTP request
|
||||
* @param response the HTTP response
|
||||
* @param callback the callback to complete
|
||||
* @param location the redirect location
|
||||
* @param location the redirect location as an absolute URI or encoded relative URI path.
|
||||
* @see #sendRedirect(Request, Response, Callback, int, String, boolean)
|
||||
*/
|
||||
static void sendRedirect(Request request, Response response, Callback callback, String location)
|
||||
|
@ -256,7 +258,7 @@ public interface Response extends Content.Sink
|
|||
* @param request the HTTP request
|
||||
* @param response the HTTP response
|
||||
* @param callback the callback to complete
|
||||
* @param location the redirect location
|
||||
* @param location the redirect location as an absolute URI or encoded relative URI path.
|
||||
* @param consumeAvailable whether to consumer the available request content
|
||||
* @see #sendRedirect(Request, Response, Callback, int, String, boolean)
|
||||
*/
|
||||
|
@ -275,9 +277,9 @@ public interface Response extends Content.Sink
|
|||
* @param response the HTTP response
|
||||
* @param callback the callback to complete
|
||||
* @param code the redirect HTTP status code
|
||||
* @param location the redirect location
|
||||
* @param location the redirect location as an absolute URI or encoded relative URI path.
|
||||
* @param consumeAvailable whether to consumer the available request content
|
||||
* @see Request#toRedirectURI(Request, String)
|
||||
* @see #toRedirectURI(Request, String)
|
||||
* @throws IllegalArgumentException if the status code is not a redirect, or the location is {@code null}
|
||||
* @throws IllegalStateException if the response is already {@link #isCommitted() committed}
|
||||
*/
|
||||
|
@ -317,11 +319,54 @@ public interface Response extends Content.Sink
|
|||
}
|
||||
}
|
||||
|
||||
response.getHeaders().put(HttpHeader.LOCATION, Request.toRedirectURI(request, location));
|
||||
response.getHeaders().put(HttpHeader.LOCATION, toRedirectURI(request, location));
|
||||
response.setStatus(code);
|
||||
response.write(true, null, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common point to generate a proper "Location" header for redirects.
|
||||
*
|
||||
* @param request the request the redirect should be based on (needed when relative locations are provided, so that
|
||||
* server name, scheme, port can be built out properly)
|
||||
* @param location the redirect location as an absolute URI or encoded relative URI path. If a relative path starts
|
||||
* with '/', then it is relative to the root, otherwise it is relative to the request.
|
||||
* @return the full redirect "Location" URL (including scheme, host, port, path, etc...)
|
||||
*/
|
||||
static String toRedirectURI(Request request, String location)
|
||||
{
|
||||
// is the URI absolute already?
|
||||
if (!URIUtil.hasScheme(location))
|
||||
{
|
||||
// The location is relative
|
||||
HttpURI uri = request.getHttpURI();
|
||||
|
||||
// Is it relative to the request?
|
||||
if (!location.startsWith("/"))
|
||||
{
|
||||
String path = uri.getPath();
|
||||
String parent = (path.endsWith("/")) ? path : URIUtil.parentPath(path);
|
||||
location = URIUtil.addEncodedPaths(parent, location);
|
||||
}
|
||||
|
||||
// Normalize out any dot dot segments
|
||||
location = URIUtil.normalizePathQuery(location);
|
||||
if (location == null)
|
||||
throw new IllegalStateException("redirect path cannot be above root");
|
||||
|
||||
// if relative redirects are not allowed?
|
||||
if (!request.getConnectionMetaData().getHttpConfiguration().isRelativeRedirectAllowed())
|
||||
{
|
||||
// make the location an absolute URI
|
||||
StringBuilder url = new StringBuilder(128);
|
||||
URIUtil.appendSchemeHostPort(url, uri.getScheme(), Request.getServerName(request), Request.getServerPort(request));
|
||||
url.append(location);
|
||||
location = url.toString();
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Adds an HTTP {@link HttpHeader#SET_COOKIE} header to the response.</p>
|
||||
*
|
||||
|
|
|
@ -34,6 +34,7 @@ public class HostHeaderCustomizerTest
|
|||
{
|
||||
Server server = new Server();
|
||||
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||
httpConfig.setRelativeRedirectAllowed(false);
|
||||
final String serverName = "test_server_name";
|
||||
final int serverPort = 23232;
|
||||
final String redirectPath = "/redirect";
|
||||
|
@ -98,6 +99,7 @@ public class HostHeaderCustomizerTest
|
|||
{
|
||||
Server server = new Server();
|
||||
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||
httpConfig.setRelativeRedirectAllowed(false);
|
||||
final String serverName = "127.0.0.1";
|
||||
final String redirectPath = "/redirect";
|
||||
httpConfig.addCustomizer(new HostHeaderCustomizer());
|
||||
|
|
|
@ -166,6 +166,8 @@ public class ResponseTest
|
|||
@Test
|
||||
public void testRedirectGET() throws Exception
|
||||
{
|
||||
server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class)
|
||||
.getHttpConfiguration().setRelativeRedirectAllowed(false);
|
||||
server.setHandler(new Handler.Abstract()
|
||||
{
|
||||
@Override
|
||||
|
@ -197,6 +199,32 @@ public class ResponseTest
|
|||
assertThat(response.get(HttpHeader.LOCATION), is("http://hostname/somewhere/else"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodedRedirectGET() throws Exception
|
||||
{
|
||||
server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class)
|
||||
.getHttpConfiguration().setRelativeRedirectAllowed(false);
|
||||
server.setHandler(new Handler.Abstract()
|
||||
{
|
||||
@Override
|
||||
public boolean handle(Request request, Response response, Callback callback)
|
||||
{
|
||||
Response.sendRedirect(request, response, callback, "somewh%65r%65?else+entirely");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
server.start();
|
||||
|
||||
String request = """
|
||||
GET /p%61th/ HTTP/1.0\r
|
||||
Host: hostname\r
|
||||
\r
|
||||
""";
|
||||
HttpTester.Response response = HttpTester.parseResponse(connector.getResponse(request));
|
||||
assertEquals(HttpStatus.MOVED_TEMPORARILY_302, response.getStatus());
|
||||
assertThat(response.get(HttpHeader.LOCATION), is("http://hostname/p%61th/somewh%65r%65?else+entirely"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelativeRedirectGET() throws Exception
|
||||
{
|
||||
|
@ -233,9 +261,67 @@ public class ResponseTest
|
|||
assertThat(response.get(HttpHeader.LOCATION), is("/somewhere/else"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestRelativeRedirectGET() throws Exception
|
||||
{
|
||||
server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class)
|
||||
.getHttpConfiguration().setRelativeRedirectAllowed(true);
|
||||
server.setHandler(new Handler.Abstract()
|
||||
{
|
||||
@Override
|
||||
public boolean handle(Request request, Response response, Callback callback)
|
||||
{
|
||||
Response.sendRedirect(request, response, callback, "somewhere/else");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
server.start();
|
||||
|
||||
String request = """
|
||||
GET /path HTTP/1.0\r
|
||||
Host: hostname\r
|
||||
\r
|
||||
""";
|
||||
HttpTester.Response response = HttpTester.parseResponse(connector.getResponse(request));
|
||||
assertEquals(HttpStatus.MOVED_TEMPORARILY_302, response.getStatus());
|
||||
assertThat(response.get(HttpHeader.LOCATION), is("/somewhere/else"));
|
||||
|
||||
request = """
|
||||
GET /path/ HTTP/1.1\r
|
||||
Host: hostname\r
|
||||
Connection: close\r
|
||||
\r
|
||||
""";
|
||||
response = HttpTester.parseResponse(connector.getResponse(request));
|
||||
assertEquals(HttpStatus.MOVED_TEMPORARILY_302, response.getStatus());
|
||||
assertThat(response.get(HttpHeader.LOCATION), is("/path/somewhere/else"));
|
||||
|
||||
request = """
|
||||
GET /path/index.html HTTP/1.1\r
|
||||
Host: hostname\r
|
||||
Connection: close\r
|
||||
\r
|
||||
""";
|
||||
response = HttpTester.parseResponse(connector.getResponse(request));
|
||||
assertEquals(HttpStatus.MOVED_TEMPORARILY_302, response.getStatus());
|
||||
assertThat(response.get(HttpHeader.LOCATION), is("/path/somewhere/else"));
|
||||
|
||||
request = """
|
||||
GET /path/to/ HTTP/1.1\r
|
||||
Host: hostname\r
|
||||
Connection: close\r
|
||||
\r
|
||||
""";
|
||||
response = HttpTester.parseResponse(connector.getResponse(request));
|
||||
assertEquals(HttpStatus.MOVED_TEMPORARILY_302, response.getStatus());
|
||||
assertThat(response.get(HttpHeader.LOCATION), is("/path/to/somewhere/else"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRedirectPOST() throws Exception
|
||||
{
|
||||
server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class)
|
||||
.getHttpConfiguration().setRelativeRedirectAllowed(false);
|
||||
server.setHandler(new Handler.Abstract()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -3636,7 +3636,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/index.html"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.html"));
|
||||
|
||||
Files.writeString(inde, "<h1>Hello Inde</h1>", UTF_8);
|
||||
rawResponse = _local.getResponse("""
|
||||
|
@ -3647,7 +3647,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/"));
|
||||
|
||||
rawResponse = _local.getResponse("""
|
||||
GET /context/dir/ HTTP/1.1\r
|
||||
|
@ -3657,7 +3657,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/index.html"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.html"));
|
||||
|
||||
if (deleteFile(index))
|
||||
{
|
||||
|
@ -3669,7 +3669,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/index.htm"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.htm"));
|
||||
|
||||
if (deleteFile(inde))
|
||||
{
|
||||
|
@ -3721,7 +3721,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3F/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3F/"));
|
||||
|
||||
rawResponse = _local.getResponse("""
|
||||
GET /context/dir%3F/ HTTP/1.1\r
|
||||
|
@ -3731,7 +3731,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3F/index.html"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3F/index.html"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3761,7 +3761,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3B/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3B/"));
|
||||
|
||||
rawResponse = _local.getResponse("""
|
||||
GET /context/dir%3B/ HTTP/1.1\r
|
||||
|
@ -3771,7 +3771,7 @@ public class ResourceHandlerTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3B/index.html"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3B/index.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -195,7 +195,7 @@ public class DefaultServletCombinationsTest
|
|||
case REDIRECT ->
|
||||
{
|
||||
expectedStatus = HttpStatus.FOUND_302;
|
||||
expected = pathInfoOnly ? "http://local/ctx/static/index.html" : "http://local/ctx/index.html";
|
||||
expected = pathInfoOnly ? "/ctx/static/index.html" : "/ctx/index.html";
|
||||
}
|
||||
case REHANDLE ->
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ public class DefaultServletCombinationsTest
|
|||
case REDIRECT ->
|
||||
{
|
||||
expectedStatus = HttpStatus.FOUND_302;
|
||||
expected = pathInfoOnly ? "http://local/ctx/static/subdirHtml/index.html" : "http://local/ctx/subdirHtml/index.html";
|
||||
expected = pathInfoOnly ? "/ctx/static/subdirHtml/index.html" : "/ctx/subdirHtml/index.html";
|
||||
}
|
||||
case REHANDLE ->
|
||||
{
|
||||
|
|
|
@ -1199,7 +1199,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/other/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/other/"));
|
||||
|
||||
// Test alt default, should see no directory listing output (dirAllowed == false per config)
|
||||
rawResponse = connector.getResponse("""
|
||||
|
@ -1451,7 +1451,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/index.html"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.html"));
|
||||
|
||||
Files.writeString(inde, "<h1>Hello Inde</h1>", UTF_8);
|
||||
rawResponse = connector.getResponse("""
|
||||
|
@ -1462,7 +1462,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/"));
|
||||
|
||||
rawResponse = connector.getResponse("""
|
||||
GET /context/dir/ HTTP/1.1\r
|
||||
|
@ -1472,7 +1472,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/index.html"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.html"));
|
||||
|
||||
if (deleteFile(index))
|
||||
{
|
||||
|
@ -1484,7 +1484,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://local/context/dir/index.htm"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.htm"));
|
||||
|
||||
if (deleteFile(inde))
|
||||
{
|
||||
|
@ -1593,7 +1593,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3F/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3F/"));
|
||||
|
||||
rawResponse = connector.getResponse("""
|
||||
GET /context/dir%3F/ HTTP/1.1\r
|
||||
|
@ -1603,7 +1603,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3F/index.html"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3F/index.html"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1635,7 +1635,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3B/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3B/"));
|
||||
|
||||
rawResponse = connector.getResponse("""
|
||||
GET /context/dir%3B/ HTTP/1.1\r
|
||||
|
@ -1645,7 +1645,7 @@ public class DefaultServletTest
|
|||
""");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://local/context/dir%3B/index.html"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3B/index.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1808,7 +1808,7 @@ public class ConstraintTest
|
|||
|
||||
response = _connector.getResponse("GET /ctx/auth/info HTTP/1.0\r\nHost:wibble.com:8888\r\n\r\n");
|
||||
assertThat(response, containsString(" 302 Found"));
|
||||
assertThat(response, containsString("http://wibble.com:8888/ctx/testLoginPage"));
|
||||
assertThat(response, containsString("/ctx/testLoginPage"));
|
||||
|
||||
String session = response.substring(response.indexOf("JSESSIONID=") + 11, response.indexOf("; Path=/ctx"));
|
||||
|
||||
|
|
|
@ -1064,7 +1064,7 @@ public abstract class RFC2616BaseTest
|
|||
|
||||
specId = "10.3 Redirection HTTP/1.0 - basic";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://myhost:1234/tests/", response.get("Location"), specId);
|
||||
assertEquals("/tests/", response.get("Location"), specId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1093,12 +1093,12 @@ public abstract class RFC2616BaseTest
|
|||
HttpTester.Response response = responses.get(0);
|
||||
String specId = "10.3 Redirection HTTP/1.1 - basic (response 1)";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://localhost/tests/", response.get("Location"), specId);
|
||||
assertEquals("/tests/", response.get("Location"), specId);
|
||||
|
||||
response = responses.get(1);
|
||||
specId = "10.3 Redirection HTTP/1.1 - basic (response 2)";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://localhost/tests/", response.get("Location"), specId);
|
||||
assertEquals("/tests/", response.get("Location"), specId);
|
||||
assertEquals("close", response.get("Connection"), specId);
|
||||
}
|
||||
|
||||
|
@ -1122,7 +1122,7 @@ public abstract class RFC2616BaseTest
|
|||
|
||||
String specId = "10.3 Redirection HTTP/1.0 w/content";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://localhost/tests/R1.txt", response.get("Location"), specId);
|
||||
assertEquals("/tests/R1.txt", response.get("Location"), specId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1145,7 +1145,7 @@ public abstract class RFC2616BaseTest
|
|||
|
||||
String specId = "10.3 Redirection HTTP/1.1 w/content";
|
||||
assertThat(specId + " [status]", response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertThat(specId + " [location]", response.get("Location"), is(getServer().getScheme() + "://localhost/tests/R2.txt"));
|
||||
assertThat(specId + " [location]", response.get("Location"), is("/tests/R2.txt"));
|
||||
assertThat(specId + " [connection]", response.get("Connection"), is("close"));
|
||||
}
|
||||
|
||||
|
|
|
@ -1329,7 +1329,7 @@ public class RequestTest
|
|||
"Connection: close\n" +
|
||||
"\n");
|
||||
assertThat(response, containsString(" 302 Found"));
|
||||
assertThat(response, containsString("Location: http://myhost/foo"));
|
||||
assertThat(response, containsString("Location: /foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -39,7 +39,6 @@ import jakarta.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
|
|||
import jakarta.servlet.annotation.ServletSecurity.TransportGuarantee;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.eclipse.jetty.ee9.nested.AbstractHandler;
|
||||
import org.eclipse.jetty.ee9.nested.ContextHandler;
|
||||
import org.eclipse.jetty.ee9.nested.HandlerWrapper;
|
||||
|
@ -1820,7 +1819,7 @@ public class ConstraintTest
|
|||
|
||||
response = _connector.getResponse("GET /ctx/auth/info HTTP/1.0\r\nHost:wibble.com:8888\r\n\r\n");
|
||||
assertThat(response, containsString(" 302 Found"));
|
||||
assertThat(response, containsString("http://wibble.com:8888/ctx/testLoginPage"));
|
||||
assertThat(response, containsString("/ctx/testLoginPage"));
|
||||
|
||||
String session = response.substring(response.indexOf("JSESSIONID=") + 11, response.indexOf("; Path=/ctx"));
|
||||
|
||||
|
|
|
@ -743,12 +743,12 @@ public class DefaultServletTest
|
|||
rawResponse = connector.getResponse("GET /context/other HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/other/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/other/"));
|
||||
|
||||
rawResponse = connector.getResponse("GET /context/other?a=b HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/other/?a=b"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/other/?a=b"));
|
||||
|
||||
rawResponse = connector.getResponse("GET /context?a=b HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
|
@ -899,25 +899,25 @@ public class DefaultServletTest
|
|||
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.html"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.html"));
|
||||
|
||||
createFile(inde, "<h1>Hello Inde</h1>");
|
||||
rawResponse = connector.getResponse("GET /context/dir HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/"));
|
||||
|
||||
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.html"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.html"));
|
||||
|
||||
if (deleteFile(index))
|
||||
{
|
||||
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.htm"));
|
||||
assertThat(response, headerValue("Location", "/context/dir/index.htm"));
|
||||
|
||||
if (deleteFile(inde))
|
||||
{
|
||||
|
@ -992,12 +992,12 @@ public class DefaultServletTest
|
|||
rawResponse = connector.getResponse("GET /context/dir%3F HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir%3F/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3F/"));
|
||||
|
||||
rawResponse = connector.getResponse("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir%3F/index.html"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3F/index.html"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1024,12 +1024,12 @@ public class DefaultServletTest
|
|||
rawResponse = connector.getResponse("GET /context/dir%3B HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir%3B/"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3B/"));
|
||||
|
||||
rawResponse = connector.getResponse("GET /context/dir%3B/ HTTP/1.0\r\n\r\n");
|
||||
response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
|
||||
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir%3B/index.html"));
|
||||
assertThat(response, containsHeaderValue("Location", "/context/dir%3B/index.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1062,7 +1062,7 @@ public abstract class RFC2616BaseTest
|
|||
|
||||
specId = "10.3 Redirection HTTP/1.0 - basic";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://myhost:1234/tests/", response.get("Location"), specId);
|
||||
assertEquals("/tests/", response.get("Location"), specId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1091,12 +1091,12 @@ public abstract class RFC2616BaseTest
|
|||
HttpTester.Response response = responses.get(0);
|
||||
String specId = "10.3 Redirection HTTP/1.1 - basic (response 1)";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://localhost/tests/", response.get("Location"), specId);
|
||||
assertEquals("/tests/", response.get("Location"), specId);
|
||||
|
||||
response = responses.get(1);
|
||||
specId = "10.3 Redirection HTTP/1.1 - basic (response 2)";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://localhost/tests/", response.get("Location"), specId);
|
||||
assertEquals("/tests/", response.get("Location"), specId);
|
||||
assertEquals("close", response.get("Connection"), specId);
|
||||
}
|
||||
|
||||
|
@ -1120,7 +1120,7 @@ public abstract class RFC2616BaseTest
|
|||
|
||||
String specId = "10.3 Redirection HTTP/1.0 w/content";
|
||||
assertThat(specId, response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertEquals(getServer().getScheme() + "://localhost/tests/R1.txt", response.get("Location"), specId);
|
||||
assertEquals("/tests/R1.txt", response.get("Location"), specId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1143,7 +1143,7 @@ public abstract class RFC2616BaseTest
|
|||
|
||||
String specId = "10.3 Redirection HTTP/1.1 w/content";
|
||||
assertThat(specId + " [status]", response.getStatus(), is(HttpStatus.FOUND_302));
|
||||
assertThat(specId + " [location]", response.get("Location"), is(getServer().getScheme() + "://localhost/tests/R2.txt"));
|
||||
assertThat(specId + " [location]", response.get("Location"), is("/tests/R2.txt"));
|
||||
assertThat(specId + " [connection]", response.get("Connection"), is("close"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue