Search in sources :

Example 1 with HttpHeader

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));
}
Also used : HttpRequest(com.azure.core.http.HttpRequest) HttpHeaders(com.azure.core.http.HttpHeaders) HttpHeader(com.azure.core.http.HttpHeader) HttpClient(com.azure.core.http.HttpClient) QuarkusUnitTest(io.quarkus.test.QuarkusUnitTest) Test(org.junit.jupiter.api.Test)

Example 2 with HttpHeader

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);
}
Also used : HttpHeaders(com.azure.core.http.HttpHeaders) HttpHeader(com.azure.core.http.HttpHeader)

Aggregations

HttpHeader (com.azure.core.http.HttpHeader)2 HttpHeaders (com.azure.core.http.HttpHeaders)2 HttpClient (com.azure.core.http.HttpClient)1 HttpRequest (com.azure.core.http.HttpRequest)1 QuarkusUnitTest (io.quarkus.test.QuarkusUnitTest)1 Test (org.junit.jupiter.api.Test)1