Skip to content

Commit

Permalink
User views title of HTTPS page
Browse files Browse the repository at this point in the history
[#9462801]
  • Loading branch information
Attila Domokos and Veezus Kreist committed Feb 2, 2012
1 parent 165055d commit 7c948a7
Show file tree
Hide file tree
Showing 5 changed files with 624 additions and 25 deletions.
14 changes: 10 additions & 4 deletions app/models/vurl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,16 @@ def fetch_metadata
logger.warn "Could not fetch data for #{construct_url}."
end

def get_page
uri = URI.parse(construct_url)
Net::HTTP.start(uri.host, uri.port) do |http|
http.get(uri.request_uri, "User-Agent" => "Vurl.me Metadata Fetcher drone #9fc3po").body
def get_page(url = construct_url)
uri = URI.parse(url)
use_ssl = uri.scheme == 'https'
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => use_ssl) do |http|
http.get(uri.request_uri, "User-Agent" => "Vurl.me Metadata Fetcher drone #9fc3po")
end
if response.header['location'].present?
get_page response.header['location']
else
response.body
end
end

Expand Down
15 changes: 15 additions & 0 deletions spec/data/http_github_com.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
HTTP/1.1 301 Moved Permanently
Server: nginx/1.0.4
Date: Sat, 26 Nov 2011 20:22:06 GMT
Content-Type: text/html
Content-Length: 184
Connection: keep-alive
Location: https://github.com/

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.0.4</center>
</body>
</html>
Loading

0 comments on commit 7c948a7

Please sign in to comment.