Merge "Allow custom headers when using swift download (CLI)"
This commit is contained in:
		
							
								
								
									
										16
									
								
								bin/swift
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								bin/swift
									
									
									
									
									
								
							@@ -266,6 +266,11 @@ Optional arguments:
 | 
				
			|||||||
                        Number of threads to use for deleting containers
 | 
					                        Number of threads to use for deleting containers
 | 
				
			||||||
  --no-download         Perform download(s), but don't actually write anything
 | 
					  --no-download         Perform download(s), but don't actually write anything
 | 
				
			||||||
                        to disk
 | 
					                        to disk
 | 
				
			||||||
 | 
					  --header <header_name:header_value>
 | 
				
			||||||
 | 
					                        Adds a customized request header to the query, like
 | 
				
			||||||
 | 
					                        "Range" or "If-Match". This argument is repeatable.
 | 
				
			||||||
 | 
					                        Example --header "content-type:text/plain"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
'''.strip("\n")
 | 
					'''.strip("\n")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -294,6 +299,13 @@ def st_download(parser, args, thread_manager):
 | 
				
			|||||||
        '', '--no-download', action='store_true',
 | 
					        '', '--no-download', action='store_true',
 | 
				
			||||||
        default=False,
 | 
					        default=False,
 | 
				
			||||||
        help="Perform download(s), but don't actually write anything to disk")
 | 
					        help="Perform download(s), but don't actually write anything to disk")
 | 
				
			||||||
 | 
					    parser.add_option(
 | 
				
			||||||
 | 
					        '-H', '--header', action='append', dest='header',
 | 
				
			||||||
 | 
					        default=[],
 | 
				
			||||||
 | 
					        help='Specify a request header, as --header NAME:VALUE. '
 | 
				
			||||||
 | 
					        'Adds a customized request header to the query, like "Range" or '
 | 
				
			||||||
 | 
					        '"If-Match". This argument is repeatable. Example'
 | 
				
			||||||
 | 
					        ' --header "content-type:text/plain"')
 | 
				
			||||||
    (options, args) = parse_args(parser, args)
 | 
					    (options, args) = parse_args(parser, args)
 | 
				
			||||||
    args = args[1:]
 | 
					    args = args[1:]
 | 
				
			||||||
    if options.out_file == '-':
 | 
					    if options.out_file == '-':
 | 
				
			||||||
@@ -304,6 +316,7 @@ def st_download(parser, args, thread_manager):
 | 
				
			|||||||
        thread_manager.error('Usage: %s download %s\n%s', basename(argv[0]),
 | 
					        thread_manager.error('Usage: %s download %s\n%s', basename(argv[0]),
 | 
				
			||||||
                             st_download_options, st_download_help)
 | 
					                             st_download_options, st_download_help)
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					    req_headers = split_headers(options.header, '', thread_manager)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _download_object(queue_arg, conn):
 | 
					    def _download_object(queue_arg, conn):
 | 
				
			||||||
        if len(queue_arg) == 2:
 | 
					        if len(queue_arg) == 2:
 | 
				
			||||||
@@ -316,7 +329,8 @@ def st_download(parser, args, thread_manager):
 | 
				
			|||||||
        try:
 | 
					        try:
 | 
				
			||||||
            start_time = time()
 | 
					            start_time = time()
 | 
				
			||||||
            headers, body = \
 | 
					            headers, body = \
 | 
				
			||||||
                conn.get_object(container, obj, resp_chunk_size=65536)
 | 
					                conn.get_object(container, obj, resp_chunk_size=65536,
 | 
				
			||||||
 | 
					                                headers=req_headers)
 | 
				
			||||||
            header_receipt = time()
 | 
					            header_receipt = time()
 | 
				
			||||||
            content_type = headers.get('content-type')
 | 
					            content_type = headers.get('content-type')
 | 
				
			||||||
            if 'content-length' in headers:
 | 
					            if 'content-length' in headers:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -82,6 +82,8 @@ Downloads everything in the account (with --all), or everything in a
 | 
				
			|||||||
container, or a list of objects depending on the args given. For a single
 | 
					container, or a list of objects depending on the args given. For a single
 | 
				
			||||||
object download, you may use the -o [--output] <filename> option to
 | 
					object download, you may use the -o [--output] <filename> option to
 | 
				
			||||||
redirect the output to a specific file or if "-" then just redirect to stdout.
 | 
					redirect the output to a specific file or if "-" then just redirect to stdout.
 | 
				
			||||||
 | 
					You can specify optional headers with the repeatable cURL-like option
 | 
				
			||||||
 | 
					-H [--header].
 | 
				
			||||||
.RE
 | 
					.RE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\fBdelete\fR [\fIcommand-options\fR] [\fIcontainer\fR] [\fIobject\fR] [\fIobject\fR] [...]
 | 
					\fBdelete\fR [\fIcommand-options\fR] [\fIcontainer\fR] [\fIobject\fR] [\fIobject\fR] [...]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user