Expose bug with response codes #1565
Conversation
Here's an example of a CHANGELOG.md entry: * [#1565](https://github.com/ruby-grape/grape/pull/1565): Expose bug with response codes - [@bmarini](https://github.com/bmarini).
Generated by |
I ran into some issues trying to fix at the status method in def status(status = nil)
case status
when Symbol
raise ArgumentError, "Status code :#{status} is invalid." unless Rack::Utils::SYMBOL_TO_STATUS_CODE.keys.include?(status)
@status = Rack::Utils.status_code(status)
when Integer
@status = status
when nil
return @status if @status
case request.request_method.to_s.upcase
when Grape::Http::Headers::POST
201
when Grape::Http::Headers::DELETE
if @body.present?
200
else
204
end
else
200
end
else
raise ArgumentError, 'Status code must be Integer or Symbol.'
end
So I think the logic has to be moved til after the formatters run to know if the status should be set to 204 or not. |
This is related to the 204 no content changes made #1532 and #1549 #1550
Seems like the behavior should be as follows: