Add backward compability when method=None in FormRequest

This commit is contained in:
Claudio Salazar 2019-06-26 21:36:28 +02:00
parent 0c50879568
commit 2e4dc20393
1 changed files with 6 additions and 4 deletions

View File

@ -18,7 +18,7 @@ from scrapy.utils.response import get_base_url
class FormRequest(Request):
valid_form_methods = ['GET', 'POST', 'DIALOG']
valid_form_methods = ['GET', 'POST']
def __init__(self, *args, **kwargs):
formdata = kwargs.pop('formdata', None)
@ -50,9 +50,11 @@ class FormRequest(Request):
formdata = _get_inputs(form, formdata, dont_click, clickdata, response)
url = _get_form_url(form, kwargs.pop('url', None))
method = kwargs.pop('method', form.method).upper()
if method not in cls.valid_form_methods:
method = 'GET'
method = kwargs.pop('method', form.method)
if method is not None:
method = method.upper()
if method not in cls.valid_form_methods:
method = 'GET'
return cls(url=url, method=method, formdata=formdata, **kwargs)