Skip to content

should not process form data if it is a GET method #1994

@catatsuy

Description

@catatsuy

I would like to make another suggestion on this issue. #1787

The implementation of Go is a problem. But in reality there are such HTTP clients.

I think rack should ignore them.

sinatra has implemented the following response to this problem.

https://github.com/sinatra/sinatra/pull/1743/files

I think this sinatra change is terrible. However, due to the implementation of rack, sinatra has no choice but to do this.

I propose the following changes to this issue.

rack/lib/rack/request.rb

Lines 470 to 475 in a7d5649

def form_data?
type = media_type
meth = get_header(RACK_METHODOVERRIDE_ORIGINAL_METHOD) || get_header(REQUEST_METHOD)
(meth == POST && type.nil?) || FORM_DATA_MEDIA_TYPES.include?(type)
end

We will change the implementation of this function so that form_data? is false for GET methods. For example:

-         (meth == POST && type.nil?) || FORM_DATA_MEDIA_TYPES.include?(type)
+         (meth == POST && type.nil?) || (meth != GET && FORM_DATA_MEDIA_TYPES.include?(type))

We rarely send form data with the GET method.

However, this implementation would cause multiple rack tests to fail. This should be corrected in the test itself.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions