2012-10-29 14 views

答えて

4

スペックを確認してください:

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

ターゲットURLがちょうどURIがHTTPartyはSSLを使用させるのに十分でなければならない対象の終わりに:443を追加するポート443を使用することが期待されています。

ところで、HTTPS URLもSSLを使用します。

例:

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

+1。 URLに 'https://'を指定するのがベストです。ポートは自動的に443に自動的に設定されます。 –

+0

@マークトーマスとの合意。とにかく両方を使うことができます。 – robertodecurnex

3

ポートは80で、リクエストがHTTPでない限り、それが実際にデフォルトでHTTPSを使用しています。

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

ここに私の仕様です:

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 
関連する問題