Skip to content

Commit

Permalink
Fix replacing default user agent on addHeader.
Browse files Browse the repository at this point in the history
Fixes bumptech#546.
Conflicts:
	library/src/androidTest/java/com/bumptech/glide/load/model/LazyHeadersTest.java
	library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java
	library/src/test/resources/exif-orientation-examples
  • Loading branch information
sjudd committed Nov 4, 2015
1 parent 0a082ca commit d13b34b
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 @@ -117,9 +117,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
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, sdk = 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

0 comments on commit d13b34b

Please sign in to comment.