module Patchboard::Response::Headers

Constants

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”]

Public Instance Methods

parse_www_auth(string) click to toggle source
# 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