1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

21 commits

Author SHA1 Message Date
Vipul A M
822dc9133e Extract Date header to string constant in Http Response, similar to other headers 2015-01-14 12:37:58 +05:30
Mindaugas Mozūras
e312381589 Change Http::Cache::SPECIAL_KEYS from Array to Set
Slightly improves performance, for example, a simple benchmark:

```ruby
require 'benchmark/ips'
require 'set'

SPECIAL_KEYS = %w[extras no-cache max-age public must-revalidate]
SPECIAL_KEYS_SET = Set.new(SPECIAL_KEYS)
directive = 'must-revalidate'

Benchmark.ips do |x|
  x.report('array') { SPECIAL_KEYS.include?(directive) }
  x.report('set') { SPECIAL_KEYS_SET.include?(directive) }
end
```

Output:

```
-------------------------------------
   array     67926 i/100ms
     set     74054 i/100ms
-------------------------------------
   array  2318423.4 (±2.8%) i/s -   11615346 in   5.014899s
     set  3387981.8 (±4.7%) i/s -   16958366 in   5.019355s
```
2014-06-15 22:26:15 +03:00
Vipul A M
6893c23f48 drop an unused hash; change slang to SPECIAL 2013-03-19 11:00:01 +05:30
Rafael Mendonça França
b96464e7ee Check if etag exists before to do the gsub
This fix the build http://travis-ci.org/#!/rails/rails/builds/2459981
2012-09-15 11:37:50 -03:00
Steve Klabnik
b079f7a334 fix the build 2012-09-15 18:01:23 +04:00
Travis Warlick
cd461c3e64 Support for multiple etags in an If-None-Match header
This is a rebased version of #2520.

Conflicts:

	actionpack/test/dispatch/request_test.rb
2012-09-15 15:01:59 +04:00
Xavier Noria
8f58d6e507 load active_support/core_ext/object/blank in active_support/rails 2012-08-02 21:59:22 +02:00
Cainã Costa
7db29f9004 Refactor ActionDispatch::Http::Cache::Response#cache_control_headers. 2012-07-30 02:41:45 -03:00
James Tucker
0b4e8c8d84 Ensure that cache-control headers are merged
There are several aspects to this commit, that don't well fit into broken down
commits, so they are detailed here:

 * When a user uses response.headers['Cache-Control'] = some_value, then the
   documented convention in ConditionalGet is not adhered to, in this case,
   response.cache_control is ignored due to `return if
   self[CACHE_CONTROL].present?`
 * When a middleware sets cache-control headers that would clobber, they're
   converted to symbols directly, without underscores. This would lead to bugs.
 * Items that would live in :extras if set through expires_in, are placed
   directly in the @cache_control hash, and not respected in many cases
   (somewhat adhering to the aforementioned documentation).
 * Although quite useless, any directive named 'extras' would be ignored.

The general convention applied is that expires_* take precedence, but no longer
overwrite everything and expires_* are ALWAYS applied, even if the header is
set.

I am still unhappy about the contents of this commit, and the code in general.
Ideally it should be refactored to no longer use :extras. I'd likely recommend
expanding @cache_control into a class, and giving it the power to handle the
merge in a more efficient fashion. Such a commit would be a larger change that
could have additional semantic changes for other libraries unless they utilize
expires_in in very standard ways.
2012-06-18 16:49:03 -07:00
José Valim
2f689d462d Merge pull request #3479 from arvida/ensure-date-header-on-expires-in
Ensure Date header on expires_in
2012-02-18 00:28:23 -08:00
kennyj
0a958d8468 Use freezed string constant. Some string literals is used repeatedly. 2011-12-08 02:19:15 +09:00
arvida
964b2826c4 Added accessor methods for Date header 2011-10-31 10:26:05 +01:00
José Valim
3aa8f348ef Fix previous commit by allowing a proc to be given as response_body. This is deprecated and is going to be removed in future releases. 2011-05-10 16:53:57 +02:00
Aaron Patterson
9702159373 removing more unused variables 2011-01-17 14:33:34 -08:00
Krekoten' Marjan
7b2ec381ca Change def to attr_reader + alias
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-18 00:54:58 +02:00
José Valim
74dd8a3681 Move ETag and ConditionalGet logic from AD::Response to the middleware stack. 2010-10-03 21:25:22 +02:00
Xavier Noria
1ee3593d65 no need to assign if we are gonna return 2010-08-12 00:17:10 +02:00
Jeremy Kemper
ec18719b81 ETag: use body instead of @body since the method will always return a string 2010-06-28 14:46:22 -07:00
Xavier Noria
76f024ac8d adds missing requires for Object#blank? and Object#present? 2010-03-28 14:15:02 +02:00
Carlhuda
a3c6ad7d5e Fix a bunch of pending tests by providing an introspection mode for the Response object that does up-front parsing of the headers to populate things like @etag 2010-02-19 19:19:20 -08:00
José Valim
92f49b5f1e Split ActionDispatch http in smaller chunks. 2010-01-16 15:45:07 +01:00