All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.horizon.apache.internal.KeepAliveWithDefaultStrategy Maven / Gradle / Ivy

The newest version!
package com.hubspot.horizon.apache.internal;

import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.protocol.HttpContext;

public class KeepAliveWithDefaultStrategy extends DefaultConnectionKeepAliveStrategy {

  private final long defaultValue;

  public KeepAliveWithDefaultStrategy(long defaultValue) {
    this.defaultValue = defaultValue;
  }

  @Override
  public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
    long headerValue = super.getKeepAliveDuration(response, context);

    return headerValue < 0 ? defaultValue : headerValue;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy