0

In pylons project when I do request.accept_language.best_matches(), it is returning me Null. I have set 2 languages in browser (en-us and es-ar) by going to Preferences-Content- Languages in firefox.

How can I get the languages specified in the browser?

repr(request.accept_language) gives <NilAccept: <class 'webob.acceptparse.Accept'>>

Lesmana
  • 25,663
  • 9
  • 82
  • 87

1 Answers1

2

Try looking at request.headers['accept-language'], or indeed the entire request.headers object. I suspect your browser is not providing those headers.

Also, take a look at the browser request in wireshark, and the client request on the server.

Colin Dunklau
  • 3,001
  • 1
  • 20
  • 19
  • You are right, request.headers object does not have Accept Language. I have verified the http header using "Live Http Headers". This gives the header as below. GET /concept/** HTTP/1.1 Host: intern1.**.in User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0) Gecko/20100101 Firefox/4.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en,en-us;q=0.8,es;q=0.5,es-ar;q=0.3 Accept-Encoding: gzip, deflate Do you know how to come over this? or get the full header information in request.header – user1515754 Jul 10 '12 at 20:09
  • @user1515754 check what the server is receiving with tcpdump or something. The header may be getting yanked by some proxy or something, or perhaps it's getting pulled out by the web server. – Colin Dunklau Jul 10 '12 at 20:14
  • i checked using the tcpdump and wireshark. It is getting Accept-Language in http GET request. – user1515754 Jul 10 '12 at 20:51
  • @user1515754 bug in pylons then, maybe. – Colin Dunklau Jul 10 '12 at 22:20
  • @ Colin Dunklau, No, pylons sample project is returning me the correct values. But in my actual project, it is not returning. You are absolutely right that some proxy is stripping off this value. How to debug that do u have any idea? Thanks a lot for your help. – user1515754 Jul 11 '12 at 00:12