Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
netclient: cookie names with + (or spaces)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-01-24 (16:23)
From: Hendrik Tews <tews@c...>
Subject: netclient: cookie names with + (or spaces)

mailman seems to give out cookies with names that contain ``+''.
When I do curl -c ... or look into firefox I see
``robin-cvs-commits+admin'' as cookie name. It might also be that
curl and firefox are buggy and the name is really
``robin-cvs-commits admin''.

There are several fixes needed in netclient to work with such

First One has to add ``+'' in the name regexp for get_set_cookie
    which I got in :

    let nv_re = Pcre.regexp "^([-a-zA-Z0-9_.+]+)(=(.*))?$"

This way I get robin-cvs-commits+admin as cookie name, but when I
set it Nethttp.Header.set_cookie the ``+'' is encoded and the
cookie is not recognized by mailman.

I worked around this rather clumsy:

		  (if c.Nethttp.cookie_name = "robin-cvs-commits+admin" then 
		     "robin-cvs-commits admin"

Another possibility is to change in get_set_cookie

	{ Nethttp.cookie_name = Netencoding.Url.decode ~plus:false n;


	{ Nethttp.cookie_name = Netencoding.Url.decode ~plus:true n;

this way I get of course ``robin-cvs-commits admin'' as cookie

I believe get_set_cookie should be in sync with set_cookie.
Therefore, which one is wrong? Must/are cookie names be URL-encoded
in the header?