1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-24 17:16:12 +01:00

- become curl compatible, switch to "PUT" method when using -T upload file parameter

This commit is contained in:
Adrian Schröter 2011-09-23 12:11:14 +02:00
parent f98758e902
commit da7445c192

View File

@ -6092,7 +6092,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('-d', '--data', default=None, metavar='STRING', @cmdln.option('-d', '--data', default=None, metavar='STRING',
help='specify string data for e.g. POST') help='specify string data for e.g. POST')
@cmdln.option('-T', '-f', '--file', default=None, metavar='FILE', @cmdln.option('-T', '-f', '--file', default=None, metavar='FILE',
help='specify filename for e.g. PUT or DELETE') help='specify filename to upload, uses PUT mode by default')
@cmdln.option('-a', '--add-header', default=None, metavar='NAME STRING', @cmdln.option('-a', '--add-header', default=None, metavar='NAME STRING',
nargs=2, action='append', dest='headers', nargs=2, action='append', dest='headers',
help='add the specified header to the request') help='add the specified header to the request')
@ -6119,6 +6119,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not opts.method in ['GET', 'PUT', 'POST', 'DELETE']: if not opts.method in ['GET', 'PUT', 'POST', 'DELETE']:
sys.exit('unknown method %s' % opts.method) sys.exit('unknown method %s' % opts.method)
# default is PUT when uploading files
if opts.file and opts.method == 'GET':
opts.method = 'PUT'
if not url.startswith('http'): if not url.startswith('http'):
if not url.startswith('/'): if not url.startswith('/'):
url = '/' + url url = '/' + url