return newHttpRequest(newConversation(), uri);
}
protected Request copyRequest(HttpRequest oldRequest, URI newURI)
{
Request newRequest = newHttpRequest(oldRequest.getConversation(), newURI);
newRequest.method(oldRequest.getMethod())
.version(oldRequest.getVersion())
.content(oldRequest.getContent())
.idleTimeout(oldRequest.getIdleTimeout(), TimeUnit.MILLISECONDS)
.timeout(oldRequest.getTimeout(), TimeUnit.MILLISECONDS)
.followRedirects(oldRequest.isFollowRedirects());
for (HttpField header : oldRequest.getHeaders())
{
// We have a new URI, so skip the host header if present
if (HttpHeader.HOST == header.getHeader())
continue;
// Remove expectation headers
if (HttpHeader.EXPECT == header.getHeader())
continue;
// Remove cookies
if (HttpHeader.COOKIE == header.getHeader())
continue;
// Remove authorization headers
if (HttpHeader.AUTHORIZATION == header.getHeader() ||
HttpHeader.PROXY_AUTHORIZATION == header.getHeader())
continue;
newRequest.header(header.getName(), header.getValue());
}
return newRequest;
}