use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project dialogue by palantir.
the class InactivityValidationAwareConnectionKeepAliveStrategyTest method testKeepAliveHeaderWithTimeoutAndMax.
@Test
void testKeepAliveHeaderWithTimeoutAndMax() {
InactivityValidationAwareConnectionKeepAliveStrategy strategy = new InactivityValidationAwareConnectionKeepAliveStrategy(manager, "name");
BasicClassicHttpResponse response = new BasicClassicHttpResponse(200);
response.addHeader("Keep-Alive", "timeout=60, max=10");
TimeValue value = strategy.getKeepAliveDuration(response, CONTEXT);
TimeValue expected = TimeValue.ofSeconds(60);
assertThat(value).isEqualTo(expected);
verify(manager).setValidateAfterInactivity(eq(expected));
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project dialogue by palantir.
the class InactivityValidationAwareConnectionKeepAliveStrategyTest method testKeepAliveHeaderWithNegativeTimeout.
@Test
void testKeepAliveHeaderWithNegativeTimeout() {
InactivityValidationAwareConnectionKeepAliveStrategy strategy = new InactivityValidationAwareConnectionKeepAliveStrategy(manager, "name");
BasicClassicHttpResponse response = new BasicClassicHttpResponse(200);
response.addHeader("Keep-Alive", "timeout=-1");
TimeValue value = strategy.getKeepAliveDuration(response, CONTEXT);
assertThat(value).isEqualTo(CONTEXT.getRequestConfig().getConnectionKeepAlive());
verify(manager).setValidateAfterInactivity(eq(INITIAL_TIMEOUT));
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project dialogue by palantir.
the class InactivityValidationAwareConnectionKeepAliveStrategyTest method testNoKeepAliveHeader.
@Test
void testNoKeepAliveHeader() {
InactivityValidationAwareConnectionKeepAliveStrategy strategy = new InactivityValidationAwareConnectionKeepAliveStrategy(manager, "name");
BasicClassicHttpResponse response = new BasicClassicHttpResponse(200);
TimeValue value = strategy.getKeepAliveDuration(response, CONTEXT);
assertThat(value).isEqualTo(CONTEXT.getRequestConfig().getConnectionKeepAlive());
verify(manager).setValidateAfterInactivity(eq(INITIAL_TIMEOUT));
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project dialogue by palantir.
the class InactivityValidationAwareConnectionKeepAliveStrategyTest method testKeepAliveHeaderWithTimeoutIgnoredNon2xx.
@Test
void testKeepAliveHeaderWithTimeoutIgnoredNon2xx() {
InactivityValidationAwareConnectionKeepAliveStrategy strategy = new InactivityValidationAwareConnectionKeepAliveStrategy(manager, "name");
BasicClassicHttpResponse response = new BasicClassicHttpResponse(500);
response.addHeader("Keep-Alive", "timeout=60");
TimeValue value = strategy.getKeepAliveDuration(response, CONTEXT);
assertThat(value).isEqualTo(TimeValue.ofSeconds(60));
verify(manager, never()).setValidateAfterInactivity(any());
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project dialogue by palantir.
the class InactivityValidationAwareConnectionKeepAliveStrategyTest method testKeepAliveHeaderWithTimeout.
@Test
void testKeepAliveHeaderWithTimeout() {
InactivityValidationAwareConnectionKeepAliveStrategy strategy = new InactivityValidationAwareConnectionKeepAliveStrategy(manager, "name");
BasicClassicHttpResponse response = new BasicClassicHttpResponse(200);
response.addHeader("Keep-Alive", "timeout=60");
TimeValue value = strategy.getKeepAliveDuration(response, CONTEXT);
TimeValue expected = TimeValue.ofSeconds(60);
assertThat(value).isEqualTo(expected);
verify(manager).setValidateAfterInactivity(eq(expected));
}
Aggregations