Skip to content

Commit

Permalink
minor clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
slandelle committed Apr 28, 2015
1 parent 1d3badf commit 64acaa1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Expand Up @@ -96,6 +96,12 @@ public final static String getAuthority(Uri uri) {
return uri.getHost() + ":" + port;
}

public final static boolean isSameHostAndProtocol(Uri uri1, Uri uri2) {
return uri1.getScheme().equals(uri2.getScheme())
&& uri1.getHost().equals(uri2.getHost())
&& getDefaultPort(uri1) == getDefaultPort(uri2);
}

public final static int getDefaultPort(Uri uri) {
int port = uri.getPort();
if (port == -1)
Expand Down
Expand Up @@ -155,12 +155,8 @@ protected boolean exitAfterHandlingRedirect(//
logger.debug("Sending redirect to {}", request.getUri());

if (future.isKeepAlive() && !HttpHeaders.isTransferEncodingChunked(response) && !response.isChunked()) {

boolean redirectToSameHost = request.getUri().getScheme().equals(nextRequest.getUri().getScheme())
&& request.getUri().getHost().equals(nextRequest.getUri().getHost())
&& getDefaultPort(request.getUri()) == getDefaultPort(nextRequest.getUri());

if (redirectToSameHost) {
if (isSameHostAndProtocol(request.getUri(), nextRequest.getUri())) {
future.setReuseChannel(true);
} else {
channelManager.drainChannelAndOffer(channel, future, initialConnectionKeepAlive, initialPartition);
Expand Down
Expand Up @@ -156,12 +156,8 @@ protected boolean exitAfterHandlingRedirect(//
logger.debug("Sending redirect to {}", request.getUri());

if (future.isKeepAlive() && !HttpHeaders.isTransferEncodingChunked(response)) {

boolean redirectToSameHost = request.getUri().getScheme().equals(nextRequest.getUri().getScheme())
&& request.getUri().getHost().equals(nextRequest.getUri().getHost())
&& getDefaultPort(request.getUri()) == getDefaultPort(nextRequest.getUri());

if (redirectToSameHost) {
if (isSameHostAndProtocol(request.getUri(), nextRequest.getUri())) {
future.setReuseChannel(true);
requestSender.drainChannelAndExecuteNextRequest(channel, future, nextRequest);

Expand Down

0 comments on commit 64acaa1

Please sign in to comment.