-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove explicit proxy and user_agent configuration
- Loading branch information
Showing
6 changed files
with
22 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,30 +87,36 @@ This functionality may be replicated by inserting custom Faraday middleware. | |
|
||
### Configuration | ||
|
||
The Faraday middleware stack is now fully configurable and is exposed as a | ||
The Faraday middleware stack is now fully configurable and is exposed as a | ||
`Faraday::Builder` which can be manipulated in place: | ||
|
||
Twitter.middleware.insert_after Twitter::Response::RaiseClientError, CustomMiddleware | ||
|
||
Likewise, the middleware stack can be replaced in it's entirety: | ||
|
||
Twitter.middleware = Faraday::Builder.new(&Proc.new { |builder| | ||
Twitter.middleware = Faraday::Builder.new(&Proc.new{|builder| | ||
# Specify a middleware stack here | ||
}) | ||
|
||
As part of these configuration changes we've removed `adapter` configuration. | ||
As part of these configuration changes we've removed `adapter` configuration. | ||
If you would like to change the adapter used, you can do so by setting Faraday's | ||
`default_adapter`: | ||
|
||
Faraday.default_adapter = :some_other_adapter | ||
|
||
The adapter can also be configured as part of the middleware stack: | ||
|
||
Twitter.middleware = Faraday::Builder.new(&Proc.new { |builder| | ||
# Specify a middleware stack here | ||
builder.adapter :some_other_adapter | ||
}) | ||
|
||
The `proxy` and `user_agent` configuration have also been removed. These can be | ||
set via the `connection_options` configuration. | ||
|
||
Twitter.connection_options[:proxy] = 'http://erik:[email protected]:8080' | ||
Twitter.connection_options[:headers][:user_agent] = 'Custom User Agent' | ||
|
||
### Authentication | ||
|
||
This library now attempts to pull credentials from `ENV` if they are not | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,16 +30,14 @@ | |
|
||
before do | ||
@configuration = { | ||
:connection_options => {:timeout => 10}, | ||
:consumer_key => 'CK', | ||
:consumer_secret => 'CS', | ||
:endpoint => 'http://tumblr.com/', | ||
:media_endpoint => 'https://upload.twitter.com/', | ||
:middleware => Proc.new{}, | ||
:oauth_token => 'OT', | ||
:oauth_token_secret => 'OS', | ||
:proxy => 'http://erik:[email protected]:8080', | ||
:user_agent => 'Custom User Agent', | ||
:connection_options => {:timeout => 10}, | ||
} | ||
end | ||
|
||
|
@@ -78,15 +76,4 @@ | |
client2.current_user.screen_name.should eq 'pengwynn' | ||
end | ||
|
||
it "recursively merges connection options" do | ||
stub_get("/1/statuses/user_timeline.json"). | ||
with(:query => {:screen_name => "sferik"}, :headers => {"Accept" => "application/json", "User-Agent" => "Custom User Agent"}). | ||
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"}) | ||
client = Twitter::Client.new(:connection_options => {:headers => {:user_agent => 'Custom User Agent'}}) | ||
client.user_timeline("sferik") | ||
a_get("/1/statuses/user_timeline.json"). | ||
with(:query => {:screen_name => "sferik"}, :headers => {"User-Agent" => "Custom User Agent"}). | ||
should have_been_made | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters