YosiFZ
YosiFZ

Reputation: 7900

HttpClient change UserAgent

I am using this code to send GET request and change the user-agent for the request:

HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36");

HttpGet httppost = new HttpGet(responseURL);

HttpResponse response = null;
response = httpclient.execute(httppost);

And i want to know if the change of the User-Agent will effect on other HttpClient that i will create on my application? or there is a way to change the UserAgent only for this HttpClient?

Upvotes: 0

Views: 230

Answers (1)

Andrey  Kopeyko
Andrey Kopeyko

Reputation: 1566

No, it will not affect other instances.

You have to change User-Agent in any HttpClient instance you will create individually. The best way is to inherit HttpClient class and use yours with desired behaviour.

Upvotes: 1

Related Questions