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'>>

5
  • 1
    what is repr(request.accept_language)? Commented Jul 10, 2012 at 19:08
  • request is http request object, accept_language is one of the parameters in the http request. I get null only for this parameter, not for others like host,accept etc. Commented Jul 10, 2012 at 19:32
  • @user1515754 Read JF Sebastian's question again: he wants to know the repr of the object, not a general description of what you believe the api to be. Commented Jul 10, 2012 at 19:57
  • Sry.. the repr gives "<NilAccept: <class 'webob.acceptparse.Accept'>>" Commented Jul 10, 2012 at 20:02
  • @user1515754 Please put that in your question, and formatted appropriately. Commented Jul 10, 2012 at 20:12

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

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 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.
i checked using the tcpdump and wireshark. It is getting Accept-Language in http GET request.
@user1515754 bug in pylons then, maybe.
@ 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.