mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
ruby: function created
This commit is contained in:
@ -118,12 +118,7 @@ class HomeController < ApplicationController
|
||||
uri = URI.parse(new_file_uri) # create the request url
|
||||
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
|
||||
|
||||
if new_file_uri.start_with?('https')
|
||||
http.use_ssl = true
|
||||
if Rails.configuration.verify_peer_off == TRUE
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
|
||||
end
|
||||
end
|
||||
DocumentHelper.verify_ssl(new_file_uri, http)
|
||||
|
||||
req = Net::HTTP::Get.new(uri.request_uri) # create the get requets
|
||||
res = http.request(req)
|
||||
@ -326,12 +321,8 @@ class HomeController < ApplicationController
|
||||
uri = URI.parse(file_url) # create the request url
|
||||
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
|
||||
|
||||
if file_url.start_with?('https')
|
||||
http.use_ssl = true
|
||||
if Rails.configuration.verify_peer_off == TRUE
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
|
||||
end
|
||||
end
|
||||
DocumentHelper.verify_ssl(file_url, http)
|
||||
|
||||
req = Net::HTTP::Get.new(uri.request_uri) # create the get requets
|
||||
res = http.request(req)
|
||||
data = res.body
|
||||
|
||||
8
web/documentserver-example/ruby/app/models/document_helper.rb
Normal file → Executable file
8
web/documentserver-example/ruby/app/models/document_helper.rb
Normal file → Executable file
@ -340,7 +340,13 @@ class DocumentHelper
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# enable ignore certificate
|
||||
def verify_ssl(file_uri, http)
|
||||
if file_uri.start_with?('https') && Rails.configuration.verify_peer_off.eql?('true')
|
||||
http.use_ssl = true
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -51,12 +51,7 @@ class ServiceConverter
|
||||
uri = URI.parse(@@document_converter_url) # create the request url
|
||||
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
|
||||
|
||||
if @@document_converter_url.start_with?('https')
|
||||
http.use_ssl = true
|
||||
if Rails.configuration.verify_peer_off == TRUE
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
|
||||
end
|
||||
end
|
||||
DocumentHelper.verify_ssl(@@document_converter_url, http)
|
||||
|
||||
http.read_timeout = @@convert_timeout
|
||||
req = Net::HTTP::Post.new(uri.request_uri) # create the post request
|
||||
|
||||
@ -225,12 +225,7 @@ class TrackHelper
|
||||
uri = URI.parse(document_command_url) # parse the document command url
|
||||
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
|
||||
|
||||
if document_command_url.start_with?('https') # check if the documnent command url starts with https
|
||||
http.use_ssl = true
|
||||
if Rails.configuration.verify_peer_off == TRUE
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
|
||||
end
|
||||
end
|
||||
DocumentHelper.verify_ssl(document_command_url, http)
|
||||
|
||||
req = Net::HTTP::Post.new(uri.request_uri) # create the post request
|
||||
req.add_field("Content-Type", "application/json") # set headers
|
||||
@ -257,12 +252,7 @@ class TrackHelper
|
||||
uri = URI.parse(uristr) # parse the url string
|
||||
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
|
||||
|
||||
if uristr.start_with?('https') # check if the documnent command url starts with https
|
||||
http.use_ssl = true
|
||||
if Rails.configuration.verify_peer_off == TRUE
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
|
||||
end
|
||||
end
|
||||
DocumentHelper.verify_ssl(uristr, http)
|
||||
|
||||
req = Net::HTTP::Get.new(uri)
|
||||
res = http.request(req) # get the response
|
||||
|
||||
@ -48,6 +48,6 @@ module OnlineEditorsExampleRuby
|
||||
Rails.configuration.jwtSecret = ""
|
||||
Rails.configuration.header="Authorization"
|
||||
|
||||
Rails.configuration.verify_peer_off = TRUE
|
||||
Rails.configuration.verify_peer_off = "true"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user