Skip to content

Commit

Permalink
Use query endpoint URI scheme to configure SSL.
Browse files Browse the repository at this point in the history
Issue #64 - Use SSL for SPARQL queries where the scheme of the query
endpoint URI is https rather than expecting the default SSL port of
443.
  • Loading branch information
lkitching committed Aug 1, 2017
1 parent 573621a commit 5b21ac1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/tripod/streaming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Streaming

def self.create_http_client(uri, opts)
client = Net::HTTP.new(uri.host, uri.port)
client.use_ssl = true if uri.port.to_s == "443"
client.use_ssl = uri.scheme == 'https'
client.read_timeout = opts[:timeout_seconds] || 10
client
end
Expand Down
15 changes: 13 additions & 2 deletions spec/tripod/streaming_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,24 @@
end
end

context 'https URI with default https port' do
let(:client) { Tripod::Streaming.create_http_client(URI('https://localhost:443/sparql/query'), {}) }
context 'https URI with default port' do
let(:client) { Tripod::Streaming.create_http_client(URI('https://localhost/sparql/query'), {}) }
it 'should use ssl' do
expect(client.use_ssl?).to eq(true)
end
end

context 'https with non-default port' do
let(:client) { Tripod::Streaming.create_http_client(URI('https://localhost:4433/sparql/query'), {}) }
it 'should use ssl' do
expect(client.use_ssl?).to eq(true)
end

it 'should use specified port' do
expect(client.port).to eq(4433)
end
end

context 'with read timeout option' do
let(:read_timeout) { 5 }
let(:client) { Tripod::Streaming.create_http_client(URI('http://localhost/sparql/query'), {:timeout_seconds => read_timeout}) }
Expand Down

0 comments on commit 5b21ac1

Please sign in to comment.