2012-10-29 11 views

Antwort

4

prüfen die Angaben:

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

Die Ziel-URL wird erwartet Port verwenden 443. Sie einfach die :443 am Ende der Ziel-Zugabe sollte URI genug sein, um HTTParty Verwendung von SSL zu machen.

Übrigens verwenden HTTPS URLs auch SSL.

Beispiele:

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

+1. Am besten geben Sie 'https: //' in der URL an, da der Port automatisch auf 443 gesetzt wird. –

+0

Vereinbart mit @MarkThomas. Gut zu wissen, dass man beides trotzdem verwenden kann. – robertodecurnex

3

Es verwendet HTTPS eigentlich standardmäßig, wenn der Port 80 ist und die Anforderung 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

Hier ist meine 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 
Verwandte Themen