use of com.azure.core.http.HttpHeader in project camel-quarkus by apache.
the class VertxHttpClientTests method validateHeadersReturnAsIs.
@Test
public void validateHeadersReturnAsIs() {
HttpClient client = new VertxHttpClientProvider().createInstance();
final String singleValueHeaderName = "singleValue";
final String singleValueHeaderValue = "value";
final String multiValueHeaderName = "Multi-value";
final List<String> multiValueHeaderValue = Arrays.asList("value1", "value2");
HttpHeaders headers = new HttpHeaders().set(singleValueHeaderName, singleValueHeaderValue).set(multiValueHeaderName, multiValueHeaderValue);
StepVerifier.create(client.send(new HttpRequest(HttpMethod.GET, url(server, RETURN_HEADERS_AS_IS_PATH), headers, Flux.empty()))).assertNext(response -> {
Assertions.assertEquals(200, response.getStatusCode());
HttpHeaders responseHeaders = response.getHeaders();
HttpHeader singleValueHeader = responseHeaders.get(singleValueHeaderName);
assertEquals(singleValueHeaderName, singleValueHeader.getName());
assertEquals(singleValueHeaderValue, singleValueHeader.getValue());
HttpHeader multiValueHeader = responseHeaders.get("Multi-value");
assertEquals(multiValueHeaderName, multiValueHeader.getName());
}).expectComplete().verify(Duration.ofSeconds(10));
}
use of com.azure.core.http.HttpHeader in project ApplicationInsights-Java by microsoft.
the class QuickPulseNetworkHelper method getQuickPulseHeaderInfo.
public QuickPulseHeaderInfo getQuickPulseHeaderInfo(HttpResponse response) {
HttpHeaders headers = response.getHeaders();
QuickPulseStatus status = QuickPulseStatus.ERROR;
long servicePollingIntervalHint = -1;
String serviceEndpointRedirect = null;
for (HttpHeader header : headers) {
if (QPS_STATUS_HEADER.equalsIgnoreCase(header.getName())) {
String qpStatus = header.getValue();
if ("true".equalsIgnoreCase(qpStatus)) {
status = QuickPulseStatus.QP_IS_ON;
} else {
status = QuickPulseStatus.QP_IS_OFF;
}
} else if (QPS_SERVICE_POLLING_INTERVAL_HINT.equalsIgnoreCase(header.getName())) {
String servicePollingIntervalHintHeaderValue = header.getValue();
if (!Strings.isNullOrEmpty(servicePollingIntervalHintHeaderValue)) {
servicePollingIntervalHint = Long.parseLong(servicePollingIntervalHintHeaderValue);
}
} else if (QPS_SERVICE_ENDPOINT_REDIRECT.equalsIgnoreCase(header.getName())) {
serviceEndpointRedirect = header.getValue();
}
}
return new QuickPulseHeaderInfo(status, serviceEndpointRedirect, servicePollingIntervalHint);
}
Aggregations