2012-10-29 8 views

risposta

4

Controllare le specifiche:

https://github.com/jnunemaker/httparty/blob/82a90c1b93b076f9d2d7410123c2b5d609401a1f/spec/httparty/request_spec.rb#L41

L'URL di destinazione è prevista per utilizzare la porta 443. Basta aggiungere il :443 alla fine del target URI dovrebbe essere sufficiente a far HTTParty utilizzo di SSL.

A proposito, gli URL HTTPS utilizzeranno anche SSL.

Esempi:

http://foo.com  => no SSL 
https://foo.com => SSL 
http://foo.com:443 => SSL 
+0

+1. È preferibile specificare "https: //" nell'URL, poiché la porta verrà automaticamente impostata su 443 automaticamente. –

+0

Concordato con @MarkThomas. Buono a sapersi che puoi comunque usare entrambi. – robertodecurnex

3

Esso utilizza effettivamente HTTPS di default a meno che la porta è 80 e la richiesta è HTTP:

context "using port 80" do 
    let(:uri) { URI 'http://foobar.com' } 
    it { should_not use_ssl } 
end 

context "using port 443 for ssl" do 
    let(:uri) { URI 'https://api.foo.com/v1:443' } 
    it { should use_ssl } 
end 

context "https scheme with default port" do 
    it { should use_ssl } 
end 

context "https scheme with non-standard port" do 
    let(:uri) { URI 'https://foobar.com:123456' } 
    it { should use_ssl } 
end 

https://github.com/jnunemaker/httparty/blob/master/spec/httparty/connection_adapter_spec.rb

Ecco la mia spec:

describe Foo do 
    it 'is https' do 
    adapter = HTTParty::ConnectionAdapter.new(URI(subject.base_uri)) 
    expect(adapter.connection.use_ssl?).to eq(true) 
    end 
end