Search in sources :

Example 1 with Headers

use of com.bumptech.glide.load.model.Headers in project glide by bumptech.

the class HttpUrlFetcherServerTest method testAppliesHeadersInGlideUrl.

@Test
public void testAppliesHeadersInGlideUrl() throws Exception {
    mockWebServer.enqueue(new MockResponse().setResponseCode(200));
    String headerField = "field";
    String headerValue = "value";
    Map<String, String> headersMap = new HashMap<>();
    headersMap.put(headerField, headerValue);
    Headers headers = mock(Headers.class);
    when(headers.getHeaders()).thenReturn(headersMap);
    getFetcher(headers).loadData(Priority.HIGH, callback);
    assertThat(mockWebServer.takeRequest().getHeader(headerField)).isEqualTo(headerValue);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) HashMap(java.util.HashMap) Headers(com.bumptech.glide.load.model.Headers) Test(org.junit.Test)

Example 2 with Headers

use of com.bumptech.glide.load.model.Headers in project glide by bumptech.

the class VolleyStreamFetcherServerTest method testAppliesHeadersInGlideUrl.

@Test
public void testAppliesHeadersInGlideUrl() throws Exception {
    mockWebServer.enqueue(new MockResponse().setResponseCode(200));
    String headerField = "field";
    String headerValue = "value";
    Map<String, String> headersMap = new HashMap<>();
    headersMap.put(headerField, headerValue);
    Headers headers = mock(Headers.class);
    when(headers.getHeaders()).thenReturn(headersMap);
    getFetcher(headers).loadData(Priority.HIGH, callback);
    waitForResponseLatch.await();
    assertThat(mockWebServer.takeRequest().getHeader(headerField)).isEqualTo(headerValue);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) HashMap(java.util.HashMap) Headers(com.bumptech.glide.load.model.Headers) Test(org.junit.Test)

Aggregations

Headers (com.bumptech.glide.load.model.Headers)2 HashMap (java.util.HashMap)2 MockResponse (okhttp3.mockwebserver.MockResponse)2 Test (org.junit.Test)2