Module: Pod::HTTP
- Defined in:
- lib/cocoapods-core/http.rb
Overview
Handles HTTP requests
Class Method Summary collapse
-
.get_actual_url(url) ⇒ string
Resolve potential redirects and return the final URL.
-
.validate_url(url) ⇒ REST::response
Performs validation of a URL.
Class Method Details
.get_actual_url(url) ⇒ string
Resolve potential redirects and return the final URL.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cocoapods-core/http.rb', line 9 def self.get_actual_url(url) redirects = 0 loop do response = perform_head_request(url) if [301, 302, 303, 307, 308].include? response.status_code location = response.headers['location'].first if location =~ /:\/\// url = location else url = URI.join(url, location).to_s end redirects += 1 else break end break unless redirects < MAX_HTTP_REDIRECTS end url end |
.validate_url(url) ⇒ REST::response
Performs validation of a URL
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cocoapods-core/http.rb', line 39 def self.validate_url(url) return nil unless url =~ /^#{URI.regexp}$/ begin url = get_actual_url(url) resp = perform_head_request(url) rescue SocketError, URI::InvalidURIError, REST::Error resp = nil end resp end |