Search in sources :

Example 86 with BasicHeader

use of org.apache.http.message.BasicHeader in project crate by crate.

the class BlobIntegrationTest method testParallelAccessWithRange.

@Test
public void testParallelAccessWithRange() throws Throwable {
    String digest = uploadBigBlob();
    String expectedContent = StringUtils.repeat("abcdefghijklmnopqrstuvwxyz", 1024 * 600);
    Header[][] headers = new Header[][] { { new BasicHeader("Range", "bytes=0-") }, { new BasicHeader("Range", "bytes=10-100") }, { new BasicHeader("Range", "bytes=20-30") }, { new BasicHeader("Range", "bytes=40-50") }, { new BasicHeader("Range", "bytes=40-80") }, { new BasicHeader("Range", "bytes=10-80") }, { new BasicHeader("Range", "bytes=5-30") }, { new BasicHeader("Range", "bytes=15-3000") }, { new BasicHeader("Range", "bytes=2000-10800") }, { new BasicHeader("Range", "bytes=1500-20000") } };
    String[] expected = new String[] { expectedContent, expectedContent.substring(10, 101), expectedContent.substring(20, 31), expectedContent.substring(40, 51), expectedContent.substring(40, 81), expectedContent.substring(10, 81), expectedContent.substring(5, 31), expectedContent.substring(15, 3001), expectedContent.substring(2000, 10801), expectedContent.substring(1500, 20001) };
    String[] uris = new String[10];
    for (int i = 0; i < 10; i++) {
        uris[i] = blobUri(digest);
    }
    assertThat(mget(uris, headers, expected), is(true));
}
Also used : Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) BasicHeader(org.apache.http.message.BasicHeader) Test(org.junit.Test)

Example 87 with BasicHeader

use of org.apache.http.message.BasicHeader in project crate by crate.

the class AdminUIIntegrationTest method testBrowserJsonRequestToRoot.

@Test
public void testBrowserJsonRequestToRoot() throws IOException {
    Header[] headers = { browserHeader(), new BasicHeader("Accept", "application/json") };
    assertIsJsonInfoResponse(get("/", headers));
}
Also used : Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) BasicHeader(org.apache.http.message.BasicHeader) Test(org.junit.Test)

Example 88 with BasicHeader

use of org.apache.http.message.BasicHeader in project crate by crate.

the class RestSQLActionIntegrationTest method testSetCustomSchema.

@Test
public void testSetCustomSchema() throws IOException {
    execute("create table custom.foo (id string)");
    Header[] headers = new Header[] { new BasicHeader("Default-Schema", "custom") };
    CloseableHttpResponse response = post("{\"stmt\": \"select * from foo\"}", headers);
    assertThat(response.getStatusLine().getStatusCode(), is(200));
    response = post("{\"stmt\": \"select * from foo\"}");
    assertThat(response.getStatusLine().getStatusCode(), is(404));
    assertThat(EntityUtils.toString(response.getEntity()), containsString("TableUnknownException"));
}
Also used : BasicHeader(org.apache.http.message.BasicHeader) Header(org.apache.http.Header) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) BasicHeader(org.apache.http.message.BasicHeader) Test(org.junit.Test)

Example 89 with BasicHeader

use of org.apache.http.message.BasicHeader in project SimplifyReader by chentao0707.

the class OkHttpStack method performRequest.

@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError {
    OkHttpClient client = mClient.clone();
    int timeoutMs = request.getTimeoutMs();
    client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
    okHttpRequestBuilder.url(request.getUrl());
    Map<String, String> headers = request.getHeaders();
    for (final String name : headers.keySet()) {
        okHttpRequestBuilder.addHeader(name, headers.get(name));
    }
    for (final String name : additionalHeaders.keySet()) {
        okHttpRequestBuilder.addHeader(name, additionalHeaders.get(name));
    }
    setConnectionParametersForRequest(okHttpRequestBuilder, request);
    com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
    Call okHttpCall = client.newCall(okHttpRequest);
    Response okHttpResponse = okHttpCall.execute();
    StatusLine responseStatus = new BasicStatusLine(parseProtocol(okHttpResponse.protocol()), okHttpResponse.code(), okHttpResponse.message());
    BasicHttpResponse response = new BasicHttpResponse(responseStatus);
    response.setEntity(entityFromOkHttpResponse(okHttpResponse));
    Headers responseHeaders = okHttpResponse.headers();
    for (int i = 0, len = responseHeaders.size(); i < len; i++) {
        final String name = responseHeaders.name(i), value = responseHeaders.value(i);
        if (name != null) {
            response.addHeader(new BasicHeader(name, value));
        }
    }
    return response;
}
Also used : Call(com.squareup.okhttp.Call) OkHttpClient(com.squareup.okhttp.OkHttpClient) Headers(com.squareup.okhttp.Headers) Request(com.android.volley.Request) BasicStatusLine(org.apache.http.message.BasicStatusLine) Response(com.squareup.okhttp.Response) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) HttpResponse(org.apache.http.HttpResponse) BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) BasicHeader(org.apache.http.message.BasicHeader)

Example 90 with BasicHeader

use of org.apache.http.message.BasicHeader in project undertow by undertow-io.

the class AbstractModClusterTestBase method get.

static HttpGet get(final String context, final String host) {
    final HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + context);
    get.addHeader(new BasicHeader("Host", host));
    return get;
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) BasicHeader(org.apache.http.message.BasicHeader)

Aggregations

BasicHeader (org.apache.http.message.BasicHeader)128 Header (org.apache.http.Header)67 Test (org.junit.Test)29 List (java.util.List)21 HashMap (java.util.HashMap)19 HttpGet (org.apache.http.client.methods.HttpGet)18 BasicStatusLine (org.apache.http.message.BasicStatusLine)17 ProtocolVersion (org.apache.http.ProtocolVersion)16 StatusLine (org.apache.http.StatusLine)16 BasicHttpResponse (org.apache.http.message.BasicHttpResponse)16 IOException (java.io.IOException)15 HttpURLConnection (java.net.HttpURLConnection)15 URL (java.net.URL)15 HttpResponse (org.apache.http.HttpResponse)15 Response (org.elasticsearch.client.Response)10 ArrayList (java.util.ArrayList)9 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)9 TestHttpResponse (org.robolectric.shadows.httpclient.TestHttpResponse)9 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)8 StringEntity (org.apache.http.entity.StringEntity)8