Module: HTTPClient::Util
- Included in:
- HTTPClient
- Defined in:
- lib/httpclient.rb
Class Method Summary collapse
- .hash_find_value(hash) ⇒ Object
- .parse_challenge_param(param_str) ⇒ Object
- .uri_dirname(uri) ⇒ Object
- .uri_part_of(uri, part) ⇒ Object
Instance Method Summary collapse
Class Method Details
.hash_find_value(hash) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/httpclient.rb', line 108 def hash_find_value(hash) hash.each do |k, v| return v if yield(k, v) end nil end |
.parse_challenge_param(param_str) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/httpclient.rb', line 116 def parse_challenge_param(param_str) param = {} param_str.scan(/\s*([^\,]+(?:\\.[^\,]*)*)/).each do |str| key, value = str[0].scan(/\A([^=]+)=(.*)\z/)[0] if /\A"(.*)"\z/ =~ value value = $1.gsub(/\\(.)/, '\1') end param[key] = value end param end |
.uri_dirname(uri) ⇒ Object
101 102 103 104 105 |
# File 'lib/httpclient.rb', line 101 def uri_dirname(uri) uri = uri.clone uri.path = uri.path.sub(/\/[^\/]*\z/, '/') uri end |
.uri_part_of(uri, part) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/httpclient.rb', line 93 def uri_part_of(uri, part) ((uri.scheme == part.scheme) and (uri.host == part.host) and (uri.port == part.port) and uri.path.upcase.index(part.path.upcase) == 0) end |
Instance Method Details
#urify(uri) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/httpclient.rb', line 85 def urify(uri) if uri.is_a?(URI) uri else URI.parse(uri.to_s) end end |