Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None
(header)
| 2556 | return None |
| 2557 | |
| 2558 | def parse_auth(header): |
| 2559 | """ Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None""" |
| 2560 | try: |
| 2561 | method, data = header.split(None, 1) |
| 2562 | if method.lower() == 'basic': |
| 2563 | user, pwd = touni(base64.b64decode(tob(data))).split(':',1) |
| 2564 | return user, pwd |
| 2565 | except (KeyError, ValueError): |
| 2566 | return None |
| 2567 | |
| 2568 | def parse_range_header(header, maxlen=0): |
| 2569 | ''' Yield (start, end) ranges parsed from a HTTP Range header. Skip |