Module: Patchboard::Response::Headers
- Defined in:
- lib/patchboard/response.rb
Constant Summary collapse
- WWWAuthRegex =
This example Authorization value has two schemes: Custom and Basic The Custom scheme has two params, key and smurf The Basic scheme has one param, realm %q[Custom key=“otp.fBvQqSSlsNzJbqZcHKsylg”, smurf=“blue”, Basic realm=“foo”]
/ # keys are not quoted ([^\s,]+) = # value might be quoted "? # the value currently may not contain whitespace ([^\s,"]+) "? /x
Class Method Summary collapse
-
.parse_www_auth(string) ⇒ Object
the x flag means whitespace within the Regex definition is ignored.
Class Method Details
.parse_www_auth(string) ⇒ Object
the x flag means whitespace within the Regex definition is ignored
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/patchboard/response.rb', line 24 def parse_www_auth(string) parsed = {} # FIXME: This assumes that no quoted strings have spaces within. tokens = string.split(" ") name = tokens.shift parsed[name] = {} while token = tokens.shift # Now I have two problems if md = WWWAuthRegex.match(token) full, key, value = md.to_a parsed[name][key] = value else name = token parsed[name] = {} end end parsed end |