Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None
(header)
| 3371 | |
| 3372 | |
| 3373 | def parse_auth(header): |
| 3374 | """ Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None""" |
| 3375 | try: |
| 3376 | method, data = header.split(None, 1) |
| 3377 | if method.lower() == 'basic': |
| 3378 | user, pwd = touni(base64.b64decode(tob(data))).split(':', 1) |
| 3379 | return user, pwd |
| 3380 | except (KeyError, ValueError): |
| 3381 | return None |
| 3382 | |
| 3383 | |
| 3384 | def parse_range_header(header, maxlen=0): |