Skip to content

Commit

Permalink
Fix replacing default user agent on addHeader.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjudd committed Aug 15, 2015
1 parent 9f550c2 commit 44b41f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import com.bumptech.glide.load.model.LazyHeaders.Builder;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
Expand All @@ -18,6 +20,22 @@
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, emulateSdk = 18)
public class LazyHeadersTest {
private static final String DEFAULT_USER_AGENT = "default_user_agent";
private static final String DEFAULT_USER_AGENT_PROPERTY = "http.agent";
private String initialUserAgent;

@Before
public void setUp() {
initialUserAgent = System.getProperty(DEFAULT_USER_AGENT_PROPERTY);
System.setProperty(DEFAULT_USER_AGENT_PROPERTY, DEFAULT_USER_AGENT);
}

@After
public void tearDown() {
if (initialUserAgent != null) {
System.setProperty(DEFAULT_USER_AGENT_PROPERTY, initialUserAgent);
}
}

@Test
public void testIncludesEagerHeaders() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public static final class Builder {
}

private boolean copyOnModify = true;
private boolean isEncodingDefault = true;
private Map<String, List<LazyHeaderFactory>> headers = DEFAULT_HEADERS;
private boolean isUserAgentDefault = headers.containsKey(DEFAULT_USER_AGENT);
private boolean isEncodingDefault = true;
private boolean isUserAgentDefault = true;

/**
* Adds a value for the given header and returns this builder.
Expand Down

0 comments on commit 44b41f7

Please sign in to comment.