The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Any HTTP Experts? Need help with Accept-Language header

Last post 03-04-2010 3:29 AM by dhromed. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-03-2010 10:54 AM

    Any HTTP Experts? Need help with Accept-Language header

    So I'm having to implement multiple language support on our server by handling the Accept-Language header, and have some questions that aren't really addressed in the RFC:  http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

    So, a client can not only specify multiple languages, but can assign a quality value to each one to denote an order of preference.  i.e. from the spec,

    Accept-Language: da, en-gb;q=0.8, en;q=0.7
    would mean: "I prefer Danish, but will accept British English and other types of English."

    First, it seems WTFy to me that you're assigning quality values instead of just a comma-separated ordered list.  Makes parsing the thing that much harder because now I have to sort it.  And I really don't care whether you like british english .2 more, or .1 more.  I only care about the order.

    But on to my question: How do I handle (or do I need to handle) languages that have the same quality?  i.e. 

    Accept-Language: da, en

    Both would default to a quality of 1.  Should they go into an arbitrary order, or the order they were recieved in, or can I just consider that an invalid use case and handle it in the most convenient way for me (ignoring the second one)?

  • 03-03-2010 11:21 AM In reply to

    Re: Any HTTP Experts? Need help with Accept-Language header

    A more elaborate example is

           Accept: text/plain; q=0.5, text/html,
    text/x-dvi; q=0.8, text/x-c

    Verbally, this would be interpreted as "text/html and text/x-c are the preferred media types, but if they do not exist, then send the text/x-dvi entity, and if that does not exist, send the text/plain entity."

    vt_mruhlin:
    Both would default to a quality of 1.

    Fuck 'em.

    Manually add a value of >1 to inqualified entries, in the the order they appear, so that text/html gets 1.2, and text/x-c gets 1.1. Then sort.

    The result is utterly predictable to a user, and compliant with the example result => therefore good.


    In complex analysis, a meromorphic function on an open subset D of the complex plane is a function that is holomorphic on all D except a set of isolated points

  • 03-03-2010 5:10 PM In reply to

    Re: Any HTTP Experts? Need help with Accept-Language header

    Ah thanks.  I was only looking at the Accept-Language section, and ignoring the Accept section.  Didn't see that example.

  • 03-04-2010 3:29 AM In reply to

    Re: Any HTTP Experts? Need help with Accept-Language header

     Welcome.


    In complex analysis, a meromorphic function on an open subset D of the complex plane is a function that is holomorphic on all D except a set of isolated points

Page 1 of 1 (4 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems