mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-24 12:03:47 +00:00
Change behavior to use method GET when there are unknown methods
in the form
This commit is contained in:
parent
461682fc3d
commit
0c50879568
@ -52,7 +52,7 @@ class FormRequest(Request):
|
||||
|
||||
method = kwargs.pop('method', form.method).upper()
|
||||
if method not in cls.valid_form_methods:
|
||||
raise ValueError('Invalid form method in chosen form')
|
||||
method = 'GET'
|
||||
|
||||
return cls(url=url, method=method, formdata=formdata, **kwargs)
|
||||
|
||||
|
@ -1107,11 +1107,12 @@ class FormRequestTest(RequestTest):
|
||||
|
||||
for method in self.request_class.valid_form_methods:
|
||||
response = _buildresponse(body % method)
|
||||
r1 = self.request_class.from_response(response)
|
||||
self.assertEqual(r1.method, method)
|
||||
r = self.request_class.from_response(response)
|
||||
self.assertEqual(r.method, method)
|
||||
|
||||
response = _buildresponse(body % 'UNKNOWN')
|
||||
self.assertRaises(ValueError, self.request_class.from_response, response)
|
||||
r = self.request_class.from_response(response)
|
||||
self.assertEqual(r.method, 'GET')
|
||||
|
||||
|
||||
def _buildresponse(body, **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user