Changeset 19622 for lang/ruby

Show
Ignore:
Timestamp:
09/19/08 21:10:15 (2 months ago)
Author:
drry
Message:
  • HTTP 応答の判定を変更しました。
Location:
lang/ruby/citrus/trunk/plugins
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/citrus/trunk/plugins/aa.rb

    r6624 r19622  
    5959                        begin 
    6060                                r = http.get("/?quality=8&size=8&color=on&html=1&url=#{URI.encode(keyword, /[^-.!~*'()\w]/n)}") 
    61                                 case r.code.to_i 
    62                                 when 200 
     61                                case r 
     62                                when Net::HTTPOK # 200 
    6363                                        xml = Hpricot(r.body) 
    6464                                        m = xml.at('pre').inner_html 
  • lang/ruby/citrus/trunk/plugins/auto_uri_escape.rb

    r6866 r19622  
    4545                        res = http.head uri.request_uri, { 'User-Agent' => @ua } 
    4646                end 
    47                 case res.code.to_i 
    48                 when 200 .. 299 
     47                case res 
     48                when Net::HTTPSuccess # 2xx 
    4949                        uri.to_s 
    50                 when 300 .. 399 
     50                when Net::HTTPRedirection # 3xx 
    5151                        return uri.to_s unless res.key?('Location') 
    5252                        follow_uri(res['Location'], limit - 1) 
  • lang/ruby/citrus/trunk/plugins/http/default.rb

    r8897 r19622  
    3333                        r = http.head(uri.request_uri, headers) 
    3434                        log r.code.inspect 
    35                         case r.code.to_i 
    36                         when 200 
     35                        case r 
     36                        when Net::HTTPOK # 200 
    3737                                case r["Content-Type"] 
    3838                                when /html/ 
     
    5050                                        end 
    5151                                end 
    52                         when 401 
     52                        when Net::HTTPUnauthorized # 401 
    5353                                realm = r["WWW-Authenticate"][/Basic realm="([^"]+)"/, 1] 
    5454                                auth  = (@parent.config["http_auth"] || []).find {|e| e["host"] == uri.host and e["realm"] == realm } 
     
    5959                                        ret = realm 
    6060                                end 
    61                         when 300 .. 399 
     61                        when Net::HTTPRedirection # 300 .. 399 
    6262                                loc = URI(r["Location"]) 
    6363                                loc = uri + loc if loc.relative?