Comments (3)
Modified my json request header test to ensure that it sets the right content type: 61de2b9
from faraday.
Hi there, I ran into the same problem and found that it was because I used the Faraday.default_adapter before my middleware (in a Faraday::Connection contructor block).
Maybe this can help as I see the issue is still open.
Going from:
@connection ||= Faraday::Connection.new(:url => "http://...") do |builder|
builder.adapter Faraday.default_adapter
builder.use CookieAuth
end
to
@connection ||= Faraday::Connection.new(:url => "http://...") do |builder|
builder.use CookieAuth
builder.adapter Faraday.default_adapter
end
solved the problem for me.
What happens is that when any http method of Connection is called (falling back to Faraday::Connection#run_request), the default_adapter actually performs the request (like in Faraday::Adapter::NetHttp#call:45) before the middleware and so the modified headers are not sent to the server.
Yet the test case passes because the middeware is called (after the request) and updates the request_headers in the env.
To sums things up, just be sure to configure any "request modifier" middleware before any adapter that actually performs the request.
from faraday.
Closing this since Rick added a proper test and goodtouch explained that request middleware should be higher on the stack than the adapter
from faraday.
Related Issues (20)
- URL not included in response hash HOT 2
- Support for Ubuntu 22.04, using OpenSSL 3.0.2 (i.e. Heroku 22) HOT 1
- ArgumentError due to missing ruby2_keywords on Ruby 3.2.0 HOT 4
- 2.7.3 breaks compatibility with Addressable as URI parser HOT 5
- Impossible to make request with same-name multi-value headers HOT 6
- Remove `default_uri_parser` config HOT 3
- Header matching inconsistency with strict_mode and verify_stubbed_calls HOT 4
- Fix YARD doc for Options HOT 1
- Faraday::ConnectionFailed if proxy: "" is passed on Ruby 3.2.1
- Block private ips (allow_private_ips) HOT 3
- Multiple "already initialized constant" warnings HOT 2
- NoMethodError: undefined method `method=' for #<Faraday::RequestOptions (empty) HOT 5
- Faraday::Response - argument order causes unexpected behaviour HOT 3
- Incompatible with Firebase-admin-sdk HOT 1
- Streaming Stop with Connection Close? HOT 3
- `Faraday::Request::Json` doesn't encode the value `false` while it encodes `true` to `"true"` HOT 2
- Lots of "warning: method redefined; discarding old" printed during testing HOT 7
- Faraday using PUT with Transfer-Encoding: chunked
- Faraday::ParsingError.response_status doesn't return expected value when stubbing response HOT 5
- Missing HTTP 408 Request Timeout specific Faraday ClientError? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faraday.