Ho letto che HTTParty utilizza SSL if the port is set to 443, ma non vedo come impostare la porta. Qualcuno può chiarire questo per me?Come impostare la porta in HTTParty
6
A
risposta
4
Controllare le specifiche:
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
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
Problemi correlati
- 1. Impostare la porta nelle richieste
- 2. Come impostare la porta predefinita per Webrick?
- 3. Impostare la porta per php artisan.php serve
- 4. Come posso impostare la porta utilizzata da Emacs Server?
- 5. Porta la porta all'architettura AVR?
- 6. HTTParty con Proxy
- 7. Analisi HTTParty risposta
- 8. Come aprire la porta in centOS
- 9. invia json object con httparty
- 10. Come posso gestire gli errori con HTTParty?
- 11. Come modificare la porta JavaMail
- 12. Come impostare la porta di origine nel socket UDP in c?
- 13. Problemi compresi httparty in Ruby on Rails
- 14. Come utilizzare l'autenticazione di base con httparty in un'app Rails?
- 15. Ho cambiato la porta mysql in xampp, ora come posso ascoltare la nuova porta?
- 16. mongodb come cambiare la porta predefinita
- 17. Come specificare la porta del client iperf
- 18. POST JSON all'API utilizzando Rails e HTTParty
- 19. Come configurare la porta browser-sync
- 20. Come utilizzare la porta ZXing C#
- 21. Come eseguire PyCharm utilizzando la porta 80
- 22. Come si controlla l'URL completo generato da HTTParty?
- 23. Impossibile aprire la porta seriale in .NET
- 24. Rubino HTTParty - ottenere l'URL di reindirizzamento
- 25. Come scoprire la porta Jetty integrata dopo aver richiesto la porta disponibile casuale?
- 26. aprire la porta TCP in Python
- 27. Come impostare la larghezza massima di $ mdDialog?
- 28. Cambiare la porta predefinita Jetty
- 29. Come trovare la porta JMX in un server?
- 30. Come cambiare la porta HTTP che Play2 è in ascolto
+1. È preferibile specificare "https: //" nell'URL, poiché la porta verrà automaticamente impostata su 443 automaticamente. –
Concordato con @MarkThomas. Buono a sapersi che puoi comunque usare entrambi. – robertodecurnex