Server IP : 85.214.239.14 / Your IP : 18.217.10.152 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/usr/lib/python3/dist-packages/httplib2/ |
Upload File : |
import base64 import re import pyparsing as pp from .error import * try: # pyparsing>=3.0.0 downcaseTokens = pp.common.downcaseTokens except AttributeError: downcaseTokens = pp.downcaseTokens UNQUOTE_PAIRS = re.compile(r"\\(.)") unquote = lambda s, l, t: UNQUOTE_PAIRS.sub(r"\1", t[0][1:-1]) # https://tools.ietf.org/html/rfc7235#section-1.2 # https://tools.ietf.org/html/rfc7235#appendix-B tchar = "!#$%&'*+-.^_`|~" + pp.nums + pp.alphas token = pp.Word(tchar).setName("token") token68 = pp.Combine(pp.Word("-._~+/" + pp.nums + pp.alphas) + pp.Optional(pp.Word("=").leaveWhitespace())).setName( "token68" ) quoted_string = pp.dblQuotedString.copy().setName("quoted-string").setParseAction(unquote) auth_param_name = token.copy().setName("auth-param-name").addParseAction(downcaseTokens) auth_param = auth_param_name + pp.Suppress("=") + (quoted_string | token) params = pp.Dict(pp.delimitedList(pp.Group(auth_param))) scheme = token("scheme") challenge = scheme + (params("params") | token68("token")) authentication_info = params.copy() www_authenticate = pp.delimitedList(pp.Group(challenge)) def _parse_authentication_info(headers, headername="authentication-info"): """https://tools.ietf.org/html/rfc7615 """ header = headers.get(headername, "").strip() if not header: return {} try: parsed = authentication_info.parseString(header) except pp.ParseException as ex: # print(ex.explain(ex)) raise MalformedHeader(headername) return parsed.asDict() def _parse_www_authenticate(headers, headername="www-authenticate"): """Returns a dictionary of dictionaries, one dict per auth_scheme.""" header = headers.get(headername, "").strip() if not header: return {} try: parsed = www_authenticate.parseString(header) except pp.ParseException as ex: # print(ex.explain(ex)) raise MalformedHeader(headername) retval = { challenge["scheme"].lower(): challenge["params"].asDict() if "params" in challenge else {"token": challenge.get("token")} for challenge in parsed } return retval