MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / parse_auth

Function parse_auth

21-async/mojifinder/bottle.py:2558–2566  ·  view source on GitHub ↗

Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None

(header)

Source from the content-addressed store, hash-verified

2556 return None
2557
2558def 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
2568def parse_range_header(header, maxlen=0):
2569 ''' Yield (start, end) ranges parsed from a HTTP Range header. Skip

Callers 1

authMethod · 0.85

Calls 2

touniFunction · 0.85
tobFunction · 0.85

Tested by

no test coverage detected