If you just want to set the user agent then you'll want the following:

httpost.setHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 7.0; Windows
2000)");

Thanks,

Sam



2009/5/6 Ken Krugler <[email protected]>

> I'm trying to login to my yahoo account with HttpClient 4.02b, but not
>> being
>> successful. The problem I found it browser compatibility. But I could not
>> find any docs on how to fix this.
>>
>> I am triying this:
>>
>> HttpPost httpost = new HttpPost("https://login.yahoo.com/config/login?";);
>> httpost.setHeader("httpclient.useragent", "Mozilla/5.0 (compatible; MSIE
>> 7.0; Windows 2000)");
>>
>>
>> Is this the correct way? If not what is it??
>>
>
> I'm just starting to use HttpClient 4, but here's what I'm doing:
>
>            HttpParams params = new BasicHttpParams();
>            HttpProtocolParams.setUserAgent(params, userAgentString);
>
>            SchemeRegistry schemeRegistry = new SchemeRegistry();
>            schemeRegistry.register(new Scheme("http",
> PlainSocketFactory.getSocketFactory(), 80));
>
>            ClientConnectionManager cm = new
> ThreadSafeClientConnManager(params, schemeRegistry);
>            HttpClient httpClient = new DefaultHttpClient(cm, params);
>
> And then you'd do something like:
>
>            HttpPost httppost = new HttpPost("
> https://login.yahoo.com/config/login?";);
>            HttpResponse response = httpClient.execute(httppost);
>
> -- Ken
> --
> Ken Krugler
> +1 530-210-6378
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to