mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
uri/win_uri: Make method a free text field (#49719)
* uri/win_uri: Make method a free text field Since various interfaces introduce their own HTTP method (e.g. like PROPFIND, LIST or TRACE) it's better to leave this up to the user. * Fix HTTP method check in module_utils urls * Add integration test for method UNKNOWN * Clarify the change as requested during review
This commit is contained in:
parent
81ec48c7b4
commit
4e6c113bf0
7 changed files with 50 additions and 11 deletions
|
@ -61,9 +61,10 @@ options:
|
|||
version_added: "2.0"
|
||||
method:
|
||||
description:
|
||||
- The HTTP method of the request or response. It MUST be uppercase.
|
||||
- The HTTP method of the request or response.
|
||||
- In more recent versions we do not restrict the method at the module level anymore
|
||||
but it still must be a valid method accepted by the service handling the request.
|
||||
type: str
|
||||
choices: [ CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, REFRESH, TRACE ]
|
||||
default: GET
|
||||
return_content:
|
||||
description:
|
||||
|
@ -303,6 +304,7 @@ import cgi
|
|||
import datetime
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
@ -516,7 +518,7 @@ def main():
|
|||
body=dict(type='raw'),
|
||||
body_format=dict(type='str', default='raw', choices=['form-urlencoded', 'json', 'raw']),
|
||||
src=dict(type='path'),
|
||||
method=dict(type='str', default='GET', choices=['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'REFRESH', 'TRACE']),
|
||||
method=dict(type='str', default='GET'),
|
||||
return_content=dict(type='bool', default=False),
|
||||
follow_redirects=dict(type='str', default='safe', choices=['all', 'no', 'none', 'safe', 'urllib2', 'yes']),
|
||||
creates=dict(type='path'),
|
||||
|
@ -538,7 +540,7 @@ def main():
|
|||
url = module.params['url']
|
||||
body = module.params['body']
|
||||
body_format = module.params['body_format'].lower()
|
||||
method = module.params['method']
|
||||
method = module.params['method'].upper()
|
||||
dest = module.params['dest']
|
||||
return_content = module.params['return_content']
|
||||
creates = module.params['creates']
|
||||
|
@ -548,6 +550,9 @@ def main():
|
|||
|
||||
dict_headers = module.params['headers']
|
||||
|
||||
if not re.match('^[A-Z]+$', method):
|
||||
module.fail_json(msg="Parameter 'method' needs to be a single word in uppercase, like GET or POST.")
|
||||
|
||||
if body_format == 'json':
|
||||
# Encode the body unless its a string, then assume it is pre-formatted JSON
|
||||
if not isinstance(body, string_types):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue