diff options
author | Jon Moss <me@jonathanmoss.me> | 2016-11-10 14:24:24 -0500 |
---|---|---|
committer | Jon Moss <me@jonathanmoss.me> | 2016-11-10 14:33:16 -0500 |
commit | 773f71c8a0d61a01b8afcc7359e0364a1f2a1bce (patch) | |
tree | fe68fdeced97b64475e44c5073badcedc6dda3d8 /actionpack/test/controller/streaming_test.rb | |
parent | d7b333469e347824a9b2302da674d557277014d1 (diff) | |
download | rails-773f71c8a0d61a01b8afcc7359e0364a1f2a1bce.tar.gz rails-773f71c8a0d61a01b8afcc7359e0364a1f2a1bce.tar.bz2 rails-773f71c8a0d61a01b8afcc7359e0364a1f2a1bce.zip |
Don't error on an empty CONTENT_TYPE
This commit prevents a possible issue wherein an empty CONTENT_TYPE
header is sent in a request to a Rails application, and then `request.content_mime_type`
would return `nil`. This is because the `has_content_type?` guard method
was not properly checking the validity of a request's content type; it
was only checking to see whether or not the header existed, not whether
it had a value stored inside.
Relatedly, after an internal discussion, it was determined that the
`has_content_type?` method is not meant to be part of the public API,
and is therefore changed to a `:nodoc:` method in this commit.
The test for this behavior is a little bit ugly, for two reasons. One is
that it was difficult to determine where to place the test... I figured
the best place would be with the rest of the ParamsWrapper stuff, since
that's where the original issue was. Also, we have to do some fancy
footwork in calling `dispatch` on the test's controller manually... this
is because `ActionController::TestCase` will throw an error if you try
and pass in a nil content type, which is exactly what we are trying to
test here... Because of that, we have to manually call in to the
controller, and bypass the `post` request helper.
Fixes #26912.
This is a regression in behavior between Rails versions 4.2.x and 5.0.x,
which was introduced via [this commit](https://github.com/rails/rails/commit/a9f28600e901b11a9222e34bfae8642bfb753186).
Diffstat (limited to 'actionpack/test/controller/streaming_test.rb')
0 files changed, 0 insertions, 0 deletions