changeset 3276:8570e46e41f3

Fixed client to support https
author unexist
date Mon, 29 Jan 2018 12:39:18 +0100
parents e675e776df34
children ace73c89b26a
files data/sur/client.rb
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/sur/client.rb	Mon Jan 29 12:39:05 2018 +0100
+++ b/data/sur/client.rb	Mon Jan 29 12:39:18 2018 +0100
@@ -25,7 +25,7 @@
     # Client class for interaction with the user
     class Client # {{{
       # Remote repository host
-      HOST = "http://sur.subforge.org"
+      HOST = "https://sur.subforge.org"
 
       # Header separator
       BOUNDARY = "AaB03x"
@@ -766,6 +766,8 @@
         base   = File.basename(file)
         body   = ""
 
+        http.use_ssl = uri.scheme == "https"
+
         # Assemble data
         body << "--#{BOUNDARY}\r\n"
         body << "Content-Disposition: form-data; name=\"user\"\r\n\r\n"
@@ -807,6 +809,8 @@
           http = Net::HTTP.new(uri.host, uri.port)
         end
 
+        http.use_ssl = uri.scheme == "https"
+
         # Fetch file
         http.request_get("/get/" + spec.digest) do |response|
           # Check result
@@ -917,6 +921,8 @@
         uri           = URI.parse(HOST)
         http          = Net::HTTP.new(uri.host, uri.port)
 
+        http.use_ssl = uri.scheme == "https"
+
         # Check age of cache
         if !force and File.exist?(@path_remote) and
             86400 > (Time.now - File.new(@path_remote).ctime)