square / picasso

A powerful image downloading and caching library for Android
https://square.github.io/picasso/
Apache License 2.0
18.72k stars 3.97k forks source link

custom header for every image request #1052

Open yorkwang opened 9 years ago

yorkwang commented 9 years ago

Our app has a gridview which contains a lot of images from different sources. Some images have its custom "Referer", we have to request them with different custom headers. Is there any chance to change the headers dynamically after Picasso instance has been initialized?

new Picasso.Builder(getSherlockActivity()) .downloader(okHttpDownloader) .build();

hex007 commented 7 years ago

I have an application that uses auth tokens my means of having custom generated tokens sent over referer header. This feature solves my problem. Can such a functionality be achieved?

eg. : Picasso.with(context).load(img_url).header("Referer", "ABC_XYZ").resize(x, y).placeholder(loading).error(broken).into(holder.img);

NightlyNexus commented 7 years ago

Use an OkHttp Interceptor.

hex007 commented 7 years ago

@NightlyNexus Thank you, it works wonderfully.