Com.bumptech.glide.load.httpexception: Forbidden
I want to use glide to load a url picture GlideApp.with(this).load('https://files.yande.re/image/0f1c68aa6d34fb3a7a7af855e0036377/yande.re%20404988%20arsenixc%20landscape.jpg').err
Solution 1:
I also have this error today, because I have used yande's api many times, so, I think maybe this has two possible reason, one is in one time the glide have many request so that the yande serve refuses to responce, the second one is that if you use spider to show yande's picture, you need make your spider like a Internet Expore, use some methods like add headers to http request.
In my code, I add headers, it was solved.
pictureItem = (PictureItem) getIntent().getExtras().get("PictureItem");
image = (ImageView) findViewById(R.id.image);
GlideUrl glideUrl = new GlideUrl(pictureItem.sample_url, new LazyHeaders.Builder()
.addHeader("User-Agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit / 537.36(KHTML, like Gecko) Chrome 47.0.2526.106 Safari / 537.36")
.build());
Glide.with(this)
.load(glideUrl)
.into(image);
some reference which may help you:
Glide - adding header to request
Any way, if we write some code like spider, we should think more about the website we get info from. (smile face)
Post a Comment for "Com.bumptech.glide.load.httpexception: Forbidden"