2012-10-29 8 views
6

में पोर्ट को कैसे सेट करें मैंने पढ़ा है कि HTTParty SSL if the port is set to 443 का उपयोग करता है, लेकिन मुझे पोर्ट को सेट करने का तरीका नहीं दिखाई देता है। क्या कोई मेरे लिए यह स्पष्ट कर सकता है?HTTParty

उत्तर

4

चेक चश्मा:

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

लक्ष्य यूआरएल पोर्ट 443 बस लक्ष्य के अंत में :443 जोड़ने का उपयोग करने की उम्मीद है यूआरआई HTTParty बनाने के लिए उपयोग एसएसएल पर्याप्त होना चाहिए।

वैसे, HTTPS URL भी एसएसएल का उपयोग करेंगे।

उदाहरण:

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

+1। URL में 'https: //' निर्दिष्ट करने के लिए सर्वश्रेष्ठ, क्योंकि पोर्ट स्वचालित रूप से 443 पर डिफ़ॉल्ट होगा। –

+0

@MarkThomas से सहमत हुए। यह जानकर अच्छा लगा कि आप वैसे भी दोनों का उपयोग कर सकते हैं। – robertodecurnex

3

यह वास्तव में डिफ़ॉल्ट रूप से HTTPS का उपयोग करता है, जब तक कि पोर्ट 80 है और अनुरोध है http:

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 
:

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

यहाँ मेरी कल्पना है

संबंधित मुद्दे