Fix URI::InvalidURIError raised when setting a cookie after loading a page with a space in the url (Fixes #349)