Пример #1
0
 def require_challenge(self):
     """Parses a challenge returning a :py:class:`Challenge`
     instance.  Raises BadSyntax if no challenge was found."""
     self.parse_sp()
     auth_scheme = self.require_token("auth scheme")
     params = []
     self.parse_sp()
     while self.the_word is not None:
         param_name = self.parse_token()
         if param_name is not None:
             self.parse_sp()
             self.require_separator('=')
             self.parse_sp()
             if self.is_token():
                 param_value = self.parse_token()
                 forceq = False
             else:
                 param_value = self.require_production(
                     self.parse_quoted_string(), "auth-param value")
                 forceq = True
             params.append((param_name, param_value, forceq))
         self.parse_sp()
         if not self.parse_separator(","):
             break
     if auth_scheme.lower() == "basic":
         return BasicChallenge(*params)
     else:
         return Challenge(*params)
Пример #2
0
 def require_challenge(self):
     """Parses a challenge returning a :py:class:`Challenge`
     instance.  Raises BadSyntax if no challenge was found."""
     self.parse_sp()
     auth_scheme = self.require_token("auth scheme")
     params = []
     self.parse_sp()
     while self.the_word is not None:
         param_name = self.parse_token()
         if param_name is not None:
             self.parse_sp()
             self.require_separator('=')
             self.parse_sp()
             if self.is_token():
                 param_value = self.parse_token()
                 forceq = False
             else:
                 param_value = self.require_production(
                     self.parse_quoted_string(), "auth-param value")
                 forceq = True
             params.append((param_name, param_value, forceq))
         self.parse_sp()
         if not self.parse_separator(","):
             break
     if auth_scheme.lower() == "basic":
         return BasicChallenge(*params)
     else:
         return Challenge(*params)
Пример #3
0
 def __str__(self):
     result = [self.scheme]
     params = []
     for pn, pv, pq in self._params:
         params.append("%s=%s" % (pn, grammar.quote_string(pv, force=pq)))
     if params:
         result.append(string.join(params, ', '))
     return string.join(result, ' ')
Пример #4
0
 def __str__(self):
     result = [self.scheme]
     params = []
     for pn, pv, pq in self._params:
         params.append("%s=%s" % (pn, grammar.quote_string(pv, force=pq)))
     if params:
         result.append(string.join(params, ', '))
     return string.join(result, ' ')