Commit Graph

111 Commits

Author SHA1 Message Date
Guillermo Iguaran
debe9a5cbe Multipart file uploads are very rare in API only apps so don't include Rack::TemfileReaper in default middleware stack for API only apps 2018-02-17 15:52:41 -05:00
George Claghorn
54bb2f74b5 Add Rack::TempfileReaper to tests and docs 2018-01-30 18:21:07 -05:00
Yasuo Honda
01efbc128d Handle FrozenError if it is available
This pull request handles `FrozenError` introduced by Ruby 2.5.
Refer https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/61131

Since `FrozenError` is a subclass of `RuntimeError` minitest used by master
branch can handle it, though it would be better to handle `FrozenError`
explicitly if possible.

`FrozenError` does not exist in Ruby 2.4 or lower, `frozen_error_class`
handles which exception is expected to be raised.

This pull request is intended to be merged to master,
then backported to `5-1-stable` to address #31508
2017-12-20 11:52:01 +00:00
Andrew White
456c3ffdbe Add DSL for configuring Content-Security-Policy header
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
2017-11-27 05:59:26 +00:00
Koichi ITO
7c260ae201 Fix RuboCop offenses
And enable `context_dependent` of Style/BracesAroundHashParameters cop.
2017-08-16 17:55:25 +09:00
Pat Allan
acea68de02 Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Matthew Draper
6b126ffdcd Enforce middleware ordering with a test, instead of comments
We want the actual order to be very predictable, so it's rightly defined
in code -- not with an on-the-fly tsort.

But we can do the tsort here, and then verify that it matches the
implemented ordering. This way we don't leave future readers guessing
which parts of the ordering are deliberate and which are arbitrary.
2016-12-31 08:40:01 +10:30
Matthew Draper
2c5190e329 Merge pull request #27515 from kbrock/fix_log_remote_ip_before_dispatcher_ips_settings
Allow log remote ip addres when config.action_dispatch.trusted_proxie…
2016-12-31 08:30:18 +10:30
Leonid Batizhevsky
6efdb7177b Allow log remote ip addres when config.action_dispatch.trusted_proxies passed 2016-12-30 15:57:32 -05:00
Akira Matsuda
e8ba0c0f21 "Use assert_nil if expecting nil. This will fail in minitest 6." 2016-12-25 02:29:52 +09:00
Rafael Mendonça França
fda5afeb79
Remove deprecated code in ssl middleware 2016-10-10 01:35:59 -03:00
Rafael Mendonça França
79a5ea9ead
Remove deprecated support to :text in render 2016-10-10 00:02:52 -03:00
Michael Grosser
a9aed2ac94
improve error message when include assertions fail
assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message

assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
2016-09-16 12:03:37 -07:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
783763bde9 applies new string literal convention in railties/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:16:09 +02:00
Prathamesh Sonpatki
d93427840e
Remove unused boot_rails method and it's usage
- The `boot_rails` method from abstract_unit.rb is empty after 2abcdfd978fdcd491576a237e8c6b.
- So let's remove it and its usage.
2016-07-04 09:34:21 +05:30
Rafael Mendonça França
809236bc4c Fix etag expectation to work with the SHA256
It is related with 7b66d2cdb8
2016-05-06 16:30:42 -05:00
Matthew Draper
d3c9d808e3 Publish AS::Executor and AS::Reloader APIs
These should allow external code to run blocks of user code to do
"work", at a similar unit size to a web request, without needing to get
intimate with ActionDipatch.
2016-03-02 02:14:20 +10:30
Kasper Timm Hansen
fa2c96b3f7 Replace serve_static_files in tests with public_file_server.enabled.
Forgot to do it in 748b2f9, when deprecating `serve_static_files`.
2015-11-04 22:40:58 +01:00
Aaron Patterson
24f9c03d52 Revert "removing Rack::Runtime from the default stack."
This reverts commit 37423e4ff883ad5584bab983aceb4b2b759a1fd8.

Jeremy is right that we shouldn't remove this.  The fact is that many
engines are depending on this middleware to be in the default stack.
This ties our hands and forces us to keep the middleware in the stack so
that engines will work.  To be extremely clear, I think this is another
smell of "the rack stack" that we have in place.  When manipulating
middleware, we should have meaningful names for places in the req / res
lifecycle **not** have engines depend on a particular constant be in a
particular place in the stack.  This is a weakness of the API that we
have to figure out a way to address before removing the constant.

As far as timing attacks are concerned, we can reduce the granularity
such that it isn't useful information for hackers, but is still useful
for developers.
2015-10-03 14:21:31 -07:00
Aaron Patterson
37423e4ff8 removing Rack::Runtime from the default stack.
The runtime header is a potential target for timing attacks since it
returns the amount of time spent on the server (eliminating network
speed).  Total time is also not accurate for streaming responses.

The middleware can be added back via:

```ruby
config.middleware.ues ::Rack::Runtime
```
2015-10-02 14:45:31 -07:00
Aaron Patterson
38d2bf5fd1 mostly remove the ParamsParser middleware
This can still be added to the middleware stack, but is really not
necessary.  I'll follow up with a commit that deprecates the constant
2015-09-18 15:36:55 -07:00
Matthew Draper
383fed5f23 Rely on the load interlock for non-caching reloads, too 2015-07-09 03:31:30 +09:30
Matthew Draper
c37d47e308 Soften the lock requirements when eager_load is disabled
We don't need to fully disable concurrent requests: just ensure that
loads are performed in isolation.
2015-07-09 02:23:23 +09:30
Santiago Pastorino
135c059d6f Add config.api_only option to application and remove appropriate middleware when true 2015-06-11 16:54:09 -03:00
Guo Xiang Tan
a39498ae06 Allow Rack::Runtime to be deleted from middleware stack.
Fixes: https://github.com/rails/rails/issues/16433.
2015-02-19 08:44:24 +08:00
Godfrey Chan
2d04bdd86f Merge pull request #18100 from chancancode/serve_static_files
Allow static asset serving from env variable (enhanced!)
Conflicts:
	railties/CHANGELOG.md
2014-12-19 14:55:34 -08:00
Xavier Noria
112077c255 inject Rack::Lock if config.eager_load is false
If code is not eager loaded constants are loaded on demand. Constant
autoloading is not thread-safe, so if eager loading is not enabled
multi-threading should not be allowed.

This showed up in certain Capybara scenarios: Most Capybara drivers
other than Rack::Test need a web server. In particular, drivers for
JavaScript support. Capybara launches WEBrick in its own thread for
those but that per se is fine, because the spec thread and the server
thread are coordinated.

Problem comes if the page being served in the spec makes Ajax calls.
Those may hit WEBrick in parallel, and since WEBrick is multi-threaded
and allow_concurrency? returns true in the test environment before
this patch, threads are spawned to serve those parallel requests. On
the other hand, since eager_load is false by default in the test
environment, constants are not preloaded.

So the suite is autoloading constants in a multi-threaded set. That's
a receipt for paracetamol. The symptom is random obscure errors whose
messages point somehow to constant autoloading.

As a consequence of this fix for allow_concurrency? WEBrick in
Capybara scenarios no longer runs in multi-threaded mode.

Fixes #15089.
2014-09-18 23:04:08 +02:00
Akira Matsuda
4ded131181 Expectations first 2014-08-28 14:41:00 +09:00
Guillermo Iguaran
ab54ec7248 We don't need parenthesis for this 2014-08-05 11:51:12 -05:00
Arthur Neves
a7060a6e21
Fix digest ETAG test.
After
12528d4567
ETag will include a `W/` before the digest.
2014-08-05 12:40:54 -04:00
Guillermo Iguaran
2e296c8ee5 Merge pull request #12365 from jbaudanza/reorder
Move Rack::Cache after ActionDispatch::Static in the middleware stack
2013-12-01 22:42:26 -08:00
Ben Pickles
4de8851289 Expose MiddlewareStack#unshift to environment configuration. 2013-10-09 12:25:29 +01:00
Jonathan Baudanza
210d0c7b41 Move Rack::Cache after AD::Static in the stack 2013-09-25 17:06:20 -07:00
Arun Agrawal
3b03733d9e Added CheckPending middleware in default
As this middleware comes by default in a new
rails app

Added test to check omit for CheckPending when

Active Record is not included.
2013-07-15 11:22:15 +02:00
Arun Agrawal
b5f8630591 No need to add config for x_sendfile_header
Rack::Sendfile is loaded by default now
2013-07-15 10:42:52 +02:00
Guillermo Iguaran
0b61cc730e Rack::Sendfile is now included in middleware by default, change tests to reflect that 2013-07-15 00:33:09 -05:00
wangjohn
55d708d597 Calls to the application constant have been refactored to use
Rails.application when drawing routes and creating other configurations
on the application.
2013-06-10 20:59:37 -07:00
Arun Agrawal
2c86fa211b Testing CheckPending middleware 2013-06-08 21:10:15 +02:00
José Valim
9ee6f3cc8e Bring config.allow_concurrency back
Since the Rack::Lock still exists in development,
let's provide a way to disable it explicitly.
2013-03-03 13:20:44 -07:00
Guillermo Iguaran
3bccd12373 Remove BestStandardsSupport middleware 2013-01-29 14:20:58 -05:00
Rafael Mendonça França
90733e70d7 Don't use action_controller.perform_caching to enable rack-rack.
Setting the action_dispatch.rack_cache options to true or a hash should
be the way to enable it.
2012-10-18 14:34:26 -03:00
Robin Dupret
5ad7f8ab41 Use Ruby 1.9 Hash syntax in railties 2012-10-14 18:26:58 +02:00
Guillermo Iguaran
586a991830 config.action_dispatch.rack_cache should set explicitly to enable Rack::Cache 2012-10-04 21:36:00 -05:00
kennyj
1006382655 Remove unused require. 2012-08-29 01:22:06 +09:00
José Valim
11bc3487ab Remove allow_concurrency as a flag
The flag was mainly used to add a Rack::Lock middleware to
the stack, but the only scenario the lock is desired is in
development.

If you are deploying on a not-threaded server, the Rack::Lock
does not provide any benefit since you don't have concurrent
accesses. On the other hand, if you are on a threaded server,
you don't want the lock, since it defeats the purpose of using
a threaded server.

If there is someone out there, running on a thread server
and does want a lock, it can be added to your environment
as easy as: `use Rack::Lock`
2012-08-21 14:46:12 -03:00
Santiago Pastorino
449039a86d Remove ActionDispatch::Head middleware in favor of Rack::Head
Closes #7110 there's more work to do on rack-cache issue 69
2012-07-23 14:34:13 -03:00
Jeremy Kemper
42f6e9fb38 Freeze the middleware stack after it's built
So apps that accidentally add middlewares later aren't unwittingly dumping them in a black hole.

Closes #5911
2012-04-20 16:02:12 -07:00