lib/travis/client/session.rb in travis-1.7.2.travis.630.5 vs lib/travis/client/session.rb in travis-1.7.2.travis.632.5
- old
+ new
@@ -35,10 +35,11 @@
options.each_pair { |key, value| public_send("#{key}=", value) }
raise ArgumentError, "neither :uri nor :connection specified" unless connection
headers['Accept'] = 'application/vnd.travis-ci.2+json'
set_user_agent
+ check_ssl
end
def uri
connection.url_prefix.to_s if connection
end
@@ -207,11 +208,11 @@
request.headers.delete("Authorization")
end
end
case result.status
- when 0 then raise Travis::Client::Error, 'SSL error: could not verify peer'
+ when 0 then raise Travis::Client::SSLError, 'SSL error: could not verify peer'
when 200..299 then JSON.parse(result.body) rescue result.body
when 301, 303 then raw(:get, result.headers['Location'])
when 302, 307, 308 then raw(verb, result.headers['Location'])
when 401 then raise Travis::Client::NotLoggedIn, 'not logged in'
when 403 then raise Travis::Client::NotLoggedIn, 'invalid access token'
@@ -321,9 +322,15 @@
def cached(*keys)
last = keys.pop
cache = keys.inject(@cache) { |store, key| store[key] ||= {} }
cache[last] ||= yield
+ end
+
+ def check_ssl
+ raw(:head, '/') if ssl == SSL_OPTIONS
+ rescue SSLError => error
+ self.ssl = {}
end
end
end
end