Skip to content

Commit 2dcef9a

Browse files
authored
Merge pull request #1765 from jdmurphy/415_status
Use 415 status for request bodies of unsupported media type
2 parents d845a3a + 6209297 commit 2dcef9a

15 files changed

+101
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### 1.0.4 (Next)
1+
### 1.1.0 (Next)
22

33
#### Features
44

@@ -10,6 +10,7 @@
1010
* [#1762](https://github.com/ruby-grape/grape/pull/1763): Fix unsafe HTML rendering on errors - [@ctennis](https://github.com/ctennis).
1111
* [#1759](https://github.com/ruby-grape/grape/pull/1759): Update appraisal for rails_edge - [@zvkemp](https://github.com/zvkemp).
1212
* [#1758](https://github.com/ruby-grape/grape/pull/1758): Fix expanding load_path in gemspec - [@2maz](https://github.com/2maz).
13+
* [#1765](https://github.com/ruby-grape/grape/pull/1765): Use 415 when request body is of an unsupported media type - [@jdmurphy](https://github.com/jdmurphy).
1314
* Your contribution here.
1415

1516
### 1.0.3 (4/23/2018)

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ content negotiation, versioning and much more.
145145

146146
## Stable Release
147147

148-
You're reading the documentation for the next release of Grape, which should be **1.0.4**.
148+
You're reading the documentation for the next release of Grape, which should be **1.1.0**.
149149
Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
150150
The current stable release is [1.0.3](https://github.com/ruby-grape/grape/blob/v1.0.3/README.md).
151151

@@ -2551,6 +2551,9 @@ Built-in formatters are the following.
25512551
* `:serializable_hash`: use object's `serializable_hash` when available, otherwise fallback to `:json`
25522552
* `:binary`: data will be returned "as is"
25532553

2554+
If a body is present in a request to an API, with a Content-Type header value that is of an unsupported type a
2555+
"415 Unsupported Media Type" error code will be returned by Grape.
2556+
25542557
Response statuses that indicate no content as defined by [Rack](https://github.com/rack)
25552558
[here](https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L567)
25562559
will bypass serialization and the body entity - though there should be none -

UPGRADING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Upgrading Grape
22
===============
33

4+
### Upgrading to >= 1.1.0
5+
6+
#### Changes in HTTP Response Code for Unsupported Content Type
7+
8+
For PUT, POST, PATCH, and DELETE requests where a non-empty body and a "Content-Type" header is supplied that is not supported by the Grape API, Grape will no longer return a 406 "Not Acceptable" HTTP status code and will instead return a 415 "Unsupported Media Type" so that the usage of HTTP status code falls more in line with the specification of [RFC 2616](https://www.ietf.org/rfc/rfc2616.txt).
9+
410
### Upgrading to >= 1.0.0
511

612
#### Changes in XML and JSON Parsers

gemfiles/multi_json.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222
group :test do
2323
gem 'cookiejar'
2424
gem 'coveralls', '~> 0.8.17', require: false
25-
gem 'danger-toc', '~> 0.1.0'
25+
gem 'danger-toc', '~> 0.1.2'
2626
gem 'grape-entity', '~> 0.6'
2727
gem 'maruku'
2828
gem 'mime-types'

gemfiles/multi_xml.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222
group :test do
2323
gem 'cookiejar'
2424
gem 'coveralls', '~> 0.8.17', require: false
25-
gem 'danger-toc', '~> 0.1.0'
25+
gem 'danger-toc', '~> 0.1.2'
2626
gem 'grape-entity', '~> 0.6'
2727
gem 'maruku'
2828
gem 'mime-types'

gemfiles/rack_1.5.2.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222
group :test do
2323
gem 'cookiejar'
2424
gem 'coveralls', '~> 0.8.17', require: false
25-
gem 'danger-toc', '~> 0.1.0'
25+
gem 'danger-toc', '~> 0.1.2'
2626
gem 'grape-entity', '~> 0.6'
2727
gem 'maruku'
2828
gem 'mime-types'

gemfiles/rack_edge.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222
group :test do
2323
gem 'cookiejar'
2424
gem 'coveralls', '~> 0.8.17', require: false
25-
gem 'danger-toc', '~> 0.1.0'
25+
gem 'danger-toc', '~> 0.1.2'
2626
gem 'grape-entity', '~> 0.6'
2727
gem 'maruku'
2828
gem 'mime-types'

gemfiles/rails_3.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ end
2323
group :test do
2424
gem 'cookiejar'
2525
gem 'coveralls', '~> 0.8.17', require: false
26-
gem 'danger-toc', '~> 0.1.0'
26+
gem 'danger-toc', '~> 0.1.2'
2727
gem 'grape-entity', '~> 0.6'
2828
gem 'maruku'
2929
gem 'mime-types'

gemfiles/rails_4.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222
group :test do
2323
gem 'cookiejar'
2424
gem 'coveralls', '~> 0.8.17', require: false
25-
gem 'danger-toc', '~> 0.1.0'
25+
gem 'danger-toc', '~> 0.1.2'
2626
gem 'grape-entity', '~> 0.6'
2727
gem 'maruku'
2828
gem 'mime-types'

gemfiles/rails_5.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222
group :test do
2323
gem 'cookiejar'
2424
gem 'coveralls', '~> 0.8.17', require: false
25-
gem 'danger-toc', '~> 0.1.0'
25+
gem 'danger-toc', '~> 0.1.2'
2626
gem 'grape-entity', '~> 0.6'
2727
gem 'maruku'
2828
gem 'mime-types'

0 commit comments

Comments
 (0)