Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http user agent changed after 3.6.1 release #546

Closed
TomasValenta opened this issue Jul 19, 2015 · 7 comments
Closed

Http user agent changed after 3.6.1 release #546

TomasValenta opened this issue Jul 19, 2015 · 7 comments
Labels
Milestone

Comments

@TomasValenta
Copy link

Hello,
in 3.6.0 release the cusotm Http user agent look like this:

HTTP_USER_AGENT : Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0

after 3.6.1 release the same cusotm Http user agent look like this:

HTTP_USER_AGENT : Dalvik/2.1.0 (Linux; U; Android 5.1.1; LG-D855 Build/LMY48G),Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0

It's a bug or feature? Because in my app this change brought new problems ;)

@TWiStErRob
Copy link
Collaborator

Hmm, maybe both...
How do you set your custom user agent?
Do you use OkHttp integration or just Glide?

There has been some changes to user agent handling, see 3.6.1 release notes and v3.6.0...v3.6.1.
As far as I can see every precaution has been made (isUserAgentDefault) to prevent concatenating two User-Agent headers, which is what you have if I see it correctly.

@TomasValenta
Copy link
Author

Hello Róbert,

I use just Glide, the new feature from 3.6.0 release. My usage:

Glide.with(context)
    .load(HttpHeader.getUrl(source))
    .into(ViewHolder.Image);

HttpHeader class:

public class HttpHeader {

    public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0";
    public static final String APP_AGENT = "XYZ";

    public static GlideUrl getUrl(String url) {
        if (TextUtils.isEmpty(url)) {
            return null;
        }
        else return new GlideUrl(url, new LazyHeaders.Builder()
                .addHeader("User-Agent", USER_AGENT)
                .addHeader("App-agent", APP_AGENT)
                .build());
    }
}

@TWiStErRob
Copy link
Collaborator

@sjudd confirmed, it's a bug, it looks like the isUserAgentDefault is always initialized false: 487d9c5#diff-0d69682540c80f964a21f69e247fbb99R120

LazyHeaders headers = new Builder()
        .addHeader("User-Agent", "My user agent")
        .addHeader("App-agent", "My app agent")
        .build();

System.out.println(headers);
System.out.println(headers.getHeaders());

3.6.0:

LazyHeaders{headers={App-agent=[StringHeaderFactory{value='My app agent'}], User-Agent=[StringHeaderFactory{value='My user agent'}]}}
{App-agent=My app agent, User-Agent=My user agent}

3.6.1:

LazyHeaders{headers={App-agent=[StringHeaderFactory{value='My app agent'}], Accept-Encoding=[StringHeaderFactory{value='identity'}], User-Agent=[StringHeaderFactory{value='Dalvik/1.6.0 (Linux; U; Android 4.4.2; GT-I9505 Build/KOT49H)'}, StringHeaderFactory{value='My user agent'}]}}
{Accept-Encoding=identity, App-agent=My app agent, User-Agent=Dalvik/1.6.0 (Linux; U; Android 4.4.2; GT-I9505 Build/KOT49H),My user agent}

@TomasValenta workaround is really simple if you want to use Glide 3.6.1 (addHeader -> setHeader):

LazyHeaders headers = new Builder()
        .setHeader("User-Agent", "My user agent")
        .addHeader("App-agent", "My app agent")
        .build();

@TomasValenta
Copy link
Author

Thank you Róbert!

@sjudd
Copy link
Collaborator

sjudd commented Jul 21, 2015

Urk, thanks for reporting this, I'll take look!

@sjudd sjudd added the bug label Jul 21, 2015
sjudd added a commit to sjudd/glide that referenced this issue Aug 15, 2015
@TWiStErRob
Copy link
Collaborator

@sjudd This looks like it's been fixed on your 3.0 branch and has been also merged to bumptech/glide 3.0 branch, but not yet released (scheduled for 3.6.2 or 3.7.0). I thought merging a "fixes #???" commit will close the issue, but it seems that only works on master or the default branch. Closing this manually because I see the commit on the right branch.

sjudd added a commit to sjudd/glide that referenced this issue Nov 4, 2015
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
@TWiStErRob TWiStErRob added this to the 3.7.0 milestone Jan 21, 2016
@TomasValenta
Copy link
Author

Confirmed fixed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants