The downside is, middleware can't be modified after making the first request: conn.use MyMiddleware # => OK conn.get('/') conn.use AnotherMiddleware # => raises a Builder::StackLocked error On the plus side, the middleware stack is built only once and then cached as the Connection#app object. The Connection instance can always be "forked off" with the `dup` method and modified as if it were fresh.
Ensures :response_headers always get initialized Closes #50
Also: - ensure that env[:response_headers] is not available during request phase - fix headers from "Test" adapter Closes #43
…verify] = false`
Changes: - there is no `env[:response]` during the request phase - middleware should attach `on_complete` handlers to the response object returned from `@app.call(env)` call - `on_complete` handlers execute immediately if the request is finished - Builder doesn't have the `run` method anymore - the default stack is now setup as soon as the Builder object has been initialized - the inner app for the stack is set when creating the request
LIVE=1 ADAPTER=typhoeus bundle exec ruby test/adapters/live_test.rb
This is because when response is finished, middleware that was lowest on the stack (last added the callback) should get notified first.