Skip to content

Clean up "?" if there is no query in request URL #13530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,10 @@ def _encode_source_url(self, source_url):
source_hostname = parsed_source_url.netloc.rstrip('/')
source_path = unquote(parsed_source_url.path)
source_query = parsed_source_url.query
return "{}://{}{}?{}".format(
source_scheme,
source_hostname,
quote(source_path, safe='~/'),
source_query
)
result = ["{}://{}{}".format(source_scheme, source_hostname, quote(source_path, safe='~/'))]
if source_query:
result.append(source_query)
return '?'.join(result)

@classmethod
def from_blob_url(cls, blob_url, credential=None, snapshot=None, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ interactions:
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 25 Oct 2019 17:59:37 GMT
- Wed, 02 Sep 2020 21:55:35 GMT
x-ms-version:
- '2019-02-02'
- '2019-12-12'
method: PUT
uri: https://storagename.blob.core.windows.net/containere54813d5?restype=container
response:
Expand All @@ -25,15 +25,15 @@ interactions:
content-length:
- '0'
date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Wed, 02 Sep 2020 21:55:35 GMT
etag:
- '"0x8D75975197B6CE2"'
- '"0x8D84F8AEC32E712"'
last-modified:
- Fri, 25 Oct 2019 17:59:36 GMT
- Wed, 02 Sep 2020 21:55:35 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-version:
- '2019-02-02'
- '2019-12-12'
status:
code: 201
message: Created
Expand All @@ -53,15 +53,15 @@ interactions:
If-None-Match:
- '*'
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-blob-type:
- BlockBlob
x-ms-date:
- Fri, 25 Oct 2019 17:59:37 GMT
- Wed, 02 Sep 2020 21:55:36 GMT
x-ms-meta-status:
- original
x-ms-version:
- '2019-02-02'
- '2019-12-12'
method: PUT
uri: https://storagename.blob.core.windows.net/containere54813d5/blob1
response:
Expand All @@ -73,19 +73,21 @@ interactions:
content-md5:
- XrY7u+Ae7tCTyyK7j1rNww==
date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Wed, 02 Sep 2020 21:55:35 GMT
etag:
- '"0x8D759751984C5A7"'
- '"0x8D84F8AEC5020DC"'
last-modified:
- Fri, 25 Oct 2019 17:59:37 GMT
- Wed, 02 Sep 2020 21:55:36 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-content-crc64:
- vo7q9sPVKY0=
x-ms-request-server-encrypted:
- 'true'
x-ms-version:
- '2019-02-02'
- '2019-12-12'
x-ms-version-id:
- '2020-09-02T21:55:36.1680604Z'
status:
code: 201
message: Created
Expand All @@ -101,15 +103,15 @@ interactions:
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-copy-source:
- https://pyacrstoragegaji2d3zddo3.blob.core.windows.net/containere54813d5/blob1
- https://tamerdevtest.blob.core.windows.net/containere54813d5/blob1
x-ms-date:
- Fri, 25 Oct 2019 17:59:37 GMT
- Wed, 02 Sep 2020 21:55:36 GMT
x-ms-meta-status:
- copy
x-ms-version:
- '2019-02-02'
- '2019-12-12'
method: PUT
uri: https://storagename.blob.core.windows.net/containere54813d5/blob1copy
response:
Expand All @@ -119,19 +121,21 @@ interactions:
content-length:
- '0'
date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Wed, 02 Sep 2020 21:55:36 GMT
etag:
- '"0x8D75975199480F2"'
- '"0x8D84F8AEC722DFD"'
last-modified:
- Fri, 25 Oct 2019 17:59:37 GMT
- Wed, 02 Sep 2020 21:55:36 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-copy-id:
- 530e75bb-3f05-457e-9ea7-67ab48b5dabc
- 2cf9e669-0ae6-477c-bf7b-e8d0d5e49fc8
x-ms-copy-status:
- success
x-ms-version:
- '2019-02-02'
- '2019-12-12'
x-ms-version-id:
- '2020-09-02T21:55:36.3912189Z'
status:
code: 202
message: Accepted
Expand All @@ -145,38 +149,39 @@ interactions:
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 25 Oct 2019 17:59:37 GMT
- Wed, 02 Sep 2020 21:55:36 GMT
x-ms-version:
- '2019-02-02'
- '2019-12-12'
method: GET
uri: https://storagename.blob.core.windows.net/containere54813d5?include=copy&restype=container&comp=list
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults
ServiceEndpoint=\"https://storagename.blob.core.windows.net/\" ContainerName=\"containere54813d5\"><Blobs><Blob><Name>blob1</Name><Properties><Creation-Time>Fri,
25 Oct 2019 17:59:37 GMT</Creation-Time><Last-Modified>Fri, 25 Oct 2019 17:59:37
GMT</Last-Modified><Etag>0x8D759751984C5A7</Etag><Content-Length>11</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding
ServiceEndpoint=\"https://storagename.blob.core.windows.net/\" ContainerName=\"containere54813d5\"><Blobs><Blob><Name>blob1</Name><VersionId>2020-09-02T21:55:36.1680604Z</VersionId><IsCurrentVersion>true</IsCurrentVersion><Properties><Creation-Time>Wed,
02 Sep 2020 21:55:36 GMT</Creation-Time><Last-Modified>Wed, 02 Sep 2020 21:55:36
GMT</Last-Modified><Etag>0x8D84F8AEC5020DC</Etag><Content-Length>11</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding
/><Content-Language /><Content-CRC64 /><Content-MD5>XrY7u+Ae7tCTyyK7j1rNww==</Content-MD5><Cache-Control
/><Content-Disposition /><BlobType>BlockBlob</BlobType><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted></Properties></Blob><Blob><Name>blob1copy</Name><Properties><Creation-Time>Fri,
25 Oct 2019 17:59:37 GMT</Creation-Time><Last-Modified>Fri, 25 Oct 2019 17:59:37
GMT</Last-Modified><Etag>0x8D75975199480F2</Etag><Content-Length>11</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding
/><Content-Disposition /><BlobType>BlockBlob</BlobType><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted></Properties><OrMetadata
/></Blob><Blob><Name>blob1copy</Name><VersionId>2020-09-02T21:55:36.3912189Z</VersionId><IsCurrentVersion>true</IsCurrentVersion><Properties><Creation-Time>Wed,
02 Sep 2020 21:55:36 GMT</Creation-Time><Last-Modified>Wed, 02 Sep 2020 21:55:36
GMT</Last-Modified><Etag>0x8D84F8AEC722DFD</Etag><Content-Length>11</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding
/><Content-Language /><Content-CRC64 /><Content-MD5>XrY7u+Ae7tCTyyK7j1rNww==</Content-MD5><Cache-Control
/><Content-Disposition /><BlobType>BlockBlob</BlobType><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><CopyId>530e75bb-3f05-457e-9ea7-67ab48b5dabc</CopyId><CopySource>https://storagename.blob.core.windows.net/containere54813d5/blob1</CopySource><CopyStatus>success</CopyStatus><CopyProgress>11/11</CopyProgress><CopyCompletionTime>Fri,
25 Oct 2019 17:59:37 GMT</CopyCompletionTime><ServerEncrypted>true</ServerEncrypted></Properties></Blob></Blobs><NextMarker
/></EnumerationResults>"
/><Content-Disposition /><BlobType>BlockBlob</BlobType><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><CopyId>2cf9e669-0ae6-477c-bf7b-e8d0d5e49fc8</CopyId><CopySource>https://storagename.blob.core.windows.net/containere54813d5/blob1</CopySource><CopyStatus>success</CopyStatus><CopyProgress>11/11</CopyProgress><CopyCompletionTime>Wed,
02 Sep 2020 21:55:36 GMT</CopyCompletionTime><ServerEncrypted>true</ServerEncrypted></Properties><OrMetadata
/></Blob></Blobs><NextMarker /></EnumerationResults>"
headers:
content-type:
- application/xml
date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Wed, 02 Sep 2020 21:55:36 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
x-ms-version:
- '2019-02-02'
- '2019-12-12'
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@
class StorageBlockBlobTest(StorageTestCase):

def _setup(self, storage_account, key):
account_url = self.account_url(storage_account, "blob")
if not isinstance(account_url, str):
account_url = account_url.encode('utf-8')
key = key.encode('utf-8')
self.bsc = BlobServiceClient(
self.account_url(storage_account, "blob"),
account_url,
credential=key,
connection_data_block_size=4 * 1024,
max_single_put_size=32 * 1024,
Expand Down
6 changes: 5 additions & 1 deletion sdk/storage/azure-storage-blob/tests/test_page_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ def test_update_page_unicode(self, resource_group, location, storage_account, st
@GlobalStorageAccountPreparer()
def test_upload_pages_from_url(self, resource_group, location, storage_account, storage_account_key):
# Arrange
bsc = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, connection_data_block_size=4 * 1024, max_page_size=4 * 1024)
account_url = self.account_url(storage_account, "blob")
if not isinstance(account_url, str):
account_url = account_url.encode('utf-8')
storage_account_key = storage_account_key.encode('utf-8')
bsc = BlobServiceClient(account_url, credential=storage_account_key, connection_data_block_size=4 * 1024, max_page_size=4 * 1024)
self._setup(bsc)
source_blob_data = self.get_random_bytes(SOURCE_BLOB_SIZE)
source_blob_client = self._create_source_blob(bsc, source_blob_data, 0, SOURCE_BLOB_SIZE)
Expand Down