def _get_cookies(self): """ HTTP_COOKIE: theme=light; sessionToken=abc123; value=10 :return: """ if not hasattr(self, '_cookies'): cookies = {} cookie_str = self._environ.get('HTTP_COOKIE') if cookie_str: for c in cookie_str.split(';'): pos = c.find('=') if pos > 0: cookies[c[:pos].strip()] = unquote(c[pos+1:]) self._cookies = cookies return self._cookies
def test_handles_normal_string(self): assert http.unquote("foo bar").decode("utf-8") == "foo bar"
def test_handles_empty_string(self): assert http.unquote("").decode("utf-8") == ""
def test_handles_url_encoding(self): assert http.unquote("%23123").decode("utf-8") == "#123"
def test_handles_spaces(self): assert http.unquote("foo+bar+baz").decode("utf-8") == "foo bar baz"
def path_info(self): """Get request path as str. """ return unquote(self._environ.get('PATH_INFO', ''))