From af77503b0bb26cd812df073a6e18810ba67844ed Mon Sep 17 00:00:00 2001 From: tomorrownull Date: Tue, 10 Jul 2012 10:21:52 +0800 Subject: [PATCH] Fix set-cookie regexp http_response.kind_of?(Net::HTTPSeeOther) status --- lib/casclient/responses.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/casclient/responses.rb b/lib/casclient/responses.rb index 099e00e5..b57e7a79 100644 --- a/lib/casclient/responses.rb +++ b/lib/casclient/responses.rb @@ -179,10 +179,10 @@ def initialize(http_response = nil, options={}) def parse_http_response(http_response) header = http_response.to_hash - # FIXME: this regexp might be incorrect... + if header['set-cookie'] && header['set-cookie'].first && - header['set-cookie'].first =~ /tgt=([^&]+);/ + header['set-cookie'].first =~ /tgt=([^&]+)/ @tgt = $~[1] end @@ -191,7 +191,7 @@ def parse_http_response(http_response) @ticket = $~[1] end - if not ((http_response.kind_of?(Net::HTTPSuccess) || http_response.kind_of?(Net::HTTPFound)) && @ticket.present?) + if not ((http_response.kind_of?(Net::HTTPSuccess) || http_response.kind_of?(Net::HTTPFound) || http_response.kind_of?(Net::HTTPSeeOther)) && @ticket.present?) @failure = true # Try to extract the error message -- this only works with RubyCAS-Server. # For other servers we just return the entire response body (i.e. the whole error page).