Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting locale with DefaultHttpClient?

I'm using DefaultHttpClient to make an http connection. I [think] we can set the preferred locale in the http headers [http accept-language] when making a connection, which the server can check and send back content in a matching language (if it wants).

Anyone know if this is possible, or how to go about doing this with DefaultHttpClient?

Thanks

like image 332
user291701 Avatar asked Sep 06 '25 03:09

user291701


1 Answers

You have to add your header to HttpRequest object

HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(URL);
request.addHeader("Accept-Language", "en");
HttpResponse response = client.execute(request);
like image 166
Pittaya S. Avatar answered Sep 07 '25 22:09

Pittaya S.