[ 
https://issues.apache.org/jira/browse/COUCHDB-348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Filipe Manana updated COUCHDB-348:
----------------------------------

    Attachment: encs.erl

Matthew, regarding the of parsing Q values, I did it for a patch to 583. It was 
done for parsing the "Accept-Encoding" header, but it should be reusable for 
other Q values lists. I didn't find it in Mochiweb also :( I agree with yout, 
it's boring to do such a parsing function.

I add it here in a separate file with test functions. The main function is 
build_enc_lists/1, which builds 2 lists, one for Q values > 0, and the other 
with Q values == 0. It ignores white spaces all over and it's case insensitive 
(as rfc 2626 says):

test_build_lists() ->
    {[], []} = build_enc_lists(""),
    {[], [identity]} = build_enc_lists("identity;q=0"),
    {[], [identity]} = build_enc_lists("identity ;q=0"),
    {[], [identity]} = build_enc_lists(" identity; q =0 "),
    {[], [identity]} = build_enc_lists("identity ; q = 0"),
    {[], [identity]} = build_enc_lists("identity ; q= 0.0"),
    {[gzip, deflate], [identity]} = 
build_enc_lists("gzip,deflate,identity;q=0.0"),
    {[deflate, gzip], [identity]} = 
build_enc_lists("deflate,gzip,identity;q=0.0"),
    {[gzip, deflate, gzip], [identity]} = 
build_enc_lists("gzip,deflate,gzip,identity;q=0"),
    {[gzip, deflate], [identity]} = build_enc_lists("gzip, deflate , identity; 
q=0.0"),
    {[gzip, deflate], [identity]} = build_enc_lists("gzip; q=1, deflate;q=1.0, 
identity;q=0.0"),
    {[deflate, gzip], [identity]} = build_enc_lists("gzip; q=0.5, 
deflate;q=1.0, identity;q=0"),
    {[deflate, gzip], [identity]} = build_enc_lists("gzip; q=0.5, deflate , 
identity;q=0.0"),
    {[deflate, gzip], [identity]} = build_enc_lists("gzip; q=0.5, 
deflate;q=0.8, identity;q=0.0"),
    {[deflate, identity, gzip], []} = build_enc_lists("gzip; 
q=0.5,deflate,identity"),
    {[deflate, identity, identity, gzip], []} = build_enc_lists("gzip; 
q=0.5,deflate,identity, identity "),
    ok.

cheers

> / should redirect to a human readable page when accessed from a browser
> -----------------------------------------------------------------------
>
>                 Key: COUCHDB-348
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-348
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: HTTP Interface
>            Reporter: Chris Anderson
>             Fix For: 0.11
>
>         Attachments: COUCHDB_348_01.patch, COUCHDB_348_02.patch, 
> COUCHDB_348_03.patch, encs.erl
>
>
> As more people are adopting CouchDB, the number of questions along the lines 
> of "All I see is {"couchdb":"Welcome","version":"0.10.0a773399"}, what now?"
> If this page redirected to /_utils/ (or maybe something more user-focussed) 
> when the accept headers included html, we could make the first-time user 
> experience more palatable.
> There's some code in COUCHDB-234 that might be helpful here.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to