简体   繁体   English

如何使用HttpClient发出HTTP Get请求,使其看起来类似于来自iPhone的请求

[英]How can I make HTTP Get request using HttpClient to look similar to a request from iPhone

The title is a bit confusing. 标题有点混乱。 In my Android app, I am making an HttpGet request using HttpClient object. 在我的Android应用程序中,我正在使用HttpClient对象发出HttpGet请求。 I am not setting any headers so all default values. 我没有设置任何标题,所以没有所有默认值。 The request works fine and i get the response from the server. 该请求工作正常,我从服务器获得响应。

The problem is that when the same url is requested using HTTP GET request from iphone, the servers response is different. 问题是,当使用来自iPhone的HTTP GET请求请求相同的URL时,服务器响应是不同的。 So the server is looking at something, USER-AGENT may be or something else, to decide what to return. 因此服务器正在查看某些内容(USER-AGENT可能是其他内容)来决定返回什么。 I want the same thing as the server returns to iphone app. 我想要与服务器返回iphone应用相同的东西。 What can I do ie what parameters, headers or whatever can I set to make this request same as ios app. 我该怎么做,即什么参数,标头或可以设置什么,以使此请求与ios应用程序相同。

PS: I have tried setting User-Agent to PS:我尝试将User-Agent设置为

"Mozilla/5.0(Linux; U; Android 2.2; en-gb; LG-P500 Build/FRF91) 
AppleWebKit/533.0 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1" \

using following code.. 使用以下代码

client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, sUsrAgent);

also plz do not suggest checking server or making changes to the webservice as I do not have access to it. 也请不要建议检查服务器或对Web服务进行更改,因为我无权访问它。

Can you try to hit a site like this from iPhone application and check the HTML response. 你可以尝试打喜欢的网站iPhone应用程序,并检查HTML响应。 It would contain the list of headers passed by the iOS network API . 它包含iOS network API传递的标头列表。 Once you have this list then you can try to add all the headers in the Android app.. 拥有此列表后,您可以尝试在Android应用中添加所有标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM