在OSMDroid中更改用户代理 [英] Changing User Agent in OSMDroid
本文介绍了在OSMDroid中更改用户代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以更改在OSMDroid中随每个平铺请求一起发送的User Agent
?
Is it possible to change User Agent
I send with every tile request in OSMDroid?
每当我尝试下载图块时,我都会出现403 Forbidden
错误(
I'm currently getting 403 Forbidden
error whenever I try to download a tile (as described in another SO question), probably because OSMDroid itself has been banned.
推荐答案
指定用户代理的唯一方法似乎是通过以下方式修改OSMDroid的MapTileDownloader.loadTile()
方法:
It looks like the only way to specify the User Agent is to modify OSMDroid's MapTileDownloader.loadTile()
method in the following way:
final HttpClient client = new DefaultHttpClient();
final HttpUriRequest head = new HttpGet(tileURLString);
head.setHeader("User-Agent", "OSMDroid"); // Add this line
final HttpResponse response = client.execute(head);
它解决了403 Forbidden
磁贴下载问题.
It solves the 403 Forbidden
tile download problem.
这篇关于在OSMDroid中更改用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文