mirror of
https://github.com/lostisland/faraday.git
synced 2025-12-15 00:03:17 -05:00
update readme with proxy docs
This commit is contained in:
parent
e63f490693
commit
c17a3c6adb
26
README.md
26
README.md
@ -24,6 +24,17 @@ conn = Faraday.new(:url => 'http://sushi.com') do |faraday|
|
||||
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
||||
end
|
||||
|
||||
# set proxy with string
|
||||
conn.options.proxy = "http://user:password@example.org/"
|
||||
|
||||
# set proxy with hash
|
||||
conn.options.proxy = { :uri => 'http://user:passwordexample.org' }
|
||||
|
||||
# specify proxy user/pass
|
||||
conn.options.proxy = { :uri => 'http://user:pass.org',
|
||||
:user => 'user',
|
||||
:password => 'pass' }
|
||||
|
||||
## GET ##
|
||||
|
||||
response = conn.get '/nigiri/sake.json' # GET http://sushi.com/nigiri/sake.json
|
||||
@ -51,8 +62,19 @@ end
|
||||
|
||||
conn.get do |req|
|
||||
req.url '/search'
|
||||
req.options[:timeout] = 5 # open/read timeout in seconds
|
||||
req.options[:open_timeout] = 2 # connection open timeout in seconds
|
||||
req.options.timeout = 5 # open/read timeout in seconds
|
||||
req.options.open_timeout = 2 # connection open timeout in seconds
|
||||
|
||||
# set proxy with string
|
||||
req.options.proxy = "http://user:password@example.org/"
|
||||
|
||||
# set proxy with hash
|
||||
req.options.proxy = { :uri => 'http://user:passwordexample.org' }
|
||||
|
||||
# specify proxy user/pass
|
||||
req.options.proxy = { :uri => 'http://user:pass.org',
|
||||
:user => 'user',
|
||||
:password => 'pass' }
|
||||
end
|
||||
```
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user