1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

quotes qop value prior to parsing

it is very common for this header to contain this value unquoted
This commit is contained in:
Bernhard Kohler 2014-10-23 17:05:09 -05:00
parent fea7a189e8
commit c187bb6341
2 changed files with 15 additions and 1 deletions

View file

@ -44,7 +44,10 @@ module Net
private private
def parse(response_header) def parse(response_header)
response_header['www-authenticate'] =~ /Digest (.*)/ header = response_header['www-authenticate']
.gsub(/qop=(auth(?:-int)?)/, %Q(qop="\\1"))
header =~ /Digest (.*)/
params = {} params = {}
$1.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 } $1.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }
params params

View file

@ -75,6 +75,17 @@ describe Net::HTTPHeader::DigestAuthenticator do
end end
end end
context "when quality of protection (qop) is unquoted" do
before do
@digest = setup_digest({
'www-authenticate' => 'Digest realm="myhost@testrealm.com", nonce="NONCE", qop=auth',
})
end
it "should still set qop" do
authorization_header.should include(%Q(qop="auth"))
end
end
context "with unspecified quality of protection (qop)" do context "with unspecified quality of protection (qop)" do
before do before do