Glide: I want to ask a request to put cookie into header,how to?

Created on 14 Mar 2016  Â·  2Comments  Â·  Source: bumptech/glide

I use volley imagerequest to override getheader() to put cookie into request before,like this:

public Map<String, String> getHeaders() throws AuthFailureError {
    HashMap map = new HashMap();
    map.put("Cookie", "AppName=myappname;UserName=" + username);
    return map;
}

now I transfer to glide ,how do I use glide to get ?

question

Most helpful comment

you can use GlideUrl. like this.

LazyHeaders.Builder builder = new LazyHeaders.Builder()
                .addHeader("User-Agent", "your UA string")
                .addHeader("Authorization", "your basic authentication string.")
                .addHeader("Cookie", "your cookie string");

GlideUrl glideUrl = new GlideUrl(url, builder.build());

Glide.with(context).load(glideUrl).into(imageView);

All 2 comments

you can use GlideUrl. like this.

LazyHeaders.Builder builder = new LazyHeaders.Builder()
                .addHeader("User-Agent", "your UA string")
                .addHeader("Authorization", "your basic authentication string.")
                .addHeader("Cookie", "your cookie string");

GlideUrl glideUrl = new GlideUrl(url, builder.build());

Glide.with(context).load(glideUrl).into(imageView);

Yes, that's the simplest way.

You can find more info in #921 if you want to centralize authentication.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  3Comments

Tryking picture Tryking  Â·  3Comments

Morteza-Rastgoo picture Morteza-Rastgoo  Â·  3Comments

sant527 picture sant527  Â·  3Comments

PatrickMA picture PatrickMA  Â·  3Comments