fix a bug where the xml body cannot be too big (#3502)

* fix a bug where the xml body cannot be too big

* ut

* CL

* record
This commit is contained in:
JinmingHu 2022-04-05 13:15:04 +08:00 committed by GitHub
parent 04cd29039b
commit 6c0f062bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 158 additions and 6 deletions

View File

@ -1933,4 +1933,22 @@ namespace Azure { namespace Storage { namespace Test {
leaseClient.Release();
}
TEST_F(BlockBlobClientTest, MaximumBlocks)
{
auto const testName(GetTestName());
auto blobClient = GetBlockBlobClient(testName);
const std::vector<uint8_t> content(static_cast<size_t>(1), 'a');
const std::string blockId = Base64EncodeText(std::string(64, '0'));
auto blockContent = Azure::Core::IO::MemoryBodyStream(content.data(), content.size());
blobClient.StageBlock(blockId, blockContent);
std::vector<std::string> blockIds(50000, blockId);
EXPECT_NO_THROW(blobClient.CommitBlockList(blockIds));
EXPECT_EQ(
blobClient.GetProperties().Value.BlobSize,
static_cast<int64_t>(blockIds.size() * content.size()));
}
}}} // namespace Azure::Storage::Test

View File

@ -0,0 +1,128 @@
{
"networkCallRecords": [
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.4.0-beta.2 (Windows 10 Pro 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "488e96d5-a300-4658-7f2e-a03799a513b6",
"x-ms-version": "2020-08-04"
},
"Method": "PUT",
"Response": {
"BODY": "",
"REASON_PHRASE": "Created",
"STATUS_CODE": "201",
"content-length": "0",
"date": "Tue, 05 Apr 2022 04:35:57 GMT",
"etag": "\"0x8DA16BDC7108781\"",
"last-modified": "Tue, 05 Apr 2022 04:35:57 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "488e96d5-a300-4658-7f2e-a03799a513b6",
"x-ms-request-id": "f6fa231b-901e-0004-69a6-484152000000",
"x-ms-version": "2020-08-04"
},
"Url": "https://REDACTED.blob.core.windows.net/blockblobclienttestmaximumblocks?restype=container"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.4.0-beta.2 (Windows 10 Pro 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "7bd19eba-c92b-4550-47dc-8a913dbeff57",
"x-ms-version": "2020-08-04"
},
"Method": "PUT",
"Response": {
"BODY": "",
"REASON_PHRASE": "Created",
"STATUS_CODE": "201",
"content-length": "0",
"date": "Tue, 05 Apr 2022 04:35:57 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "7bd19eba-c92b-4550-47dc-8a913dbeff57",
"x-ms-content-crc64": "PPzLtEWEL4w=",
"x-ms-request-id": "f6fa2455-901e-0004-12a6-484152000000",
"x-ms-request-server-encrypted": "true",
"x-ms-version": "2020-08-04"
},
"Url": "https://REDACTED.blob.core.windows.net/blockblobclienttestmaximumblocks/MaximumBlocks?blockid=MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA%3D%3D&comp=block"
},
{
"Headers": {
"content-type": "application/xml; charset=UTF-8",
"user-agent": "azsdk-cpp-storage-blobs/12.4.0-beta.2 (Windows 10 Pro 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "a590e2ab-2de9-4eeb-625c-db8ad5e98d49",
"x-ms-version": "2020-08-04"
},
"Method": "PUT",
"Response": {
"BODY": "",
"REASON_PHRASE": "Created",
"STATUS_CODE": "201",
"content-length": "0",
"date": "Tue, 05 Apr 2022 04:36:01 GMT",
"etag": "\"0x8DA16BDC954B5D3\"",
"last-modified": "Tue, 05 Apr 2022 04:36:00 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "a590e2ab-2de9-4eeb-625c-db8ad5e98d49",
"x-ms-content-crc64": "JSucJt7HJKg=",
"x-ms-request-id": "f6fa274d-901e-0004-44a6-484152000000",
"x-ms-request-server-encrypted": "true",
"x-ms-version": "2020-08-04",
"x-ms-version-id": "2022-04-05T04:36:00.8818459Z"
},
"Url": "https://REDACTED.blob.core.windows.net/blockblobclienttestmaximumblocks/MaximumBlocks?comp=blocklist"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.4.0-beta.2 (Windows 10 Pro 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "3aef73c3-4588-4d98-7e1e-2a6d6beca62e",
"x-ms-version": "2020-08-04"
},
"Method": "HEAD",
"Response": {
"BODY": "",
"REASON_PHRASE": "OK",
"STATUS_CODE": "200",
"accept-ranges": "bytes",
"content-length": "50000",
"content-type": "application/octet-stream",
"date": "Tue, 05 Apr 2022 04:36:01 GMT",
"etag": "\"0x8DA16BDC954B5D3\"",
"last-modified": "Tue, 05 Apr 2022 04:36:00 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"vary": "Origin",
"x-ms-access-tier": "Hot",
"x-ms-access-tier-inferred": "true",
"x-ms-blob-type": "BlockBlob",
"x-ms-client-request-id": "3aef73c3-4588-4d98-7e1e-2a6d6beca62e",
"x-ms-creation-time": "Tue, 05 Apr 2022 04:36:00 GMT",
"x-ms-is-current-version": "true",
"x-ms-lease-state": "available",
"x-ms-lease-status": "unlocked",
"x-ms-request-id": "f6fa302e-901e-0004-64a6-484152000000",
"x-ms-server-encrypted": "true",
"x-ms-version": "2020-08-04",
"x-ms-version-id": "2022-04-05T04:36:00.8818459Z"
},
"Url": "https://REDACTED.blob.core.windows.net/blockblobclienttestmaximumblocks/MaximumBlocks"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.4.0-beta.2 (Windows 10 Pro 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "37e31d24-000b-4a13-71c1-3dc8fceb4126",
"x-ms-version": "2020-08-04"
},
"Method": "DELETE",
"Response": {
"BODY": "",
"REASON_PHRASE": "Accepted",
"STATUS_CODE": "202",
"content-length": "0",
"date": "Tue, 05 Apr 2022 04:36:01 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "37e31d24-000b-4a13-71c1-3dc8fceb4126",
"x-ms-request-id": "f6fa3179-901e-0004-1ca6-484152000000",
"x-ms-version": "2020-08-04"
},
"Url": "https://REDACTED.blob.core.windows.net/blockblobclienttestmaximumblocks?restype=container"
}
]
}

View File

@ -8,6 +8,8 @@
### Bugs Fixed
- Fixed a bug where we got error when XML request body is too big.
### Other Changes
## 12.2.2 (2022-03-09)

View File

@ -362,18 +362,22 @@ namespace Azure { namespace Storage { namespace _internal {
auto context = static_cast<XmlWriterContext*>(m_context);
BOOL boolValueTrue = TRUE;
WS_XML_WRITER_PROPERTY writerProperty;
writerProperty.id = WS_XML_WRITER_PROPERTY_WRITE_DECLARATION;
writerProperty.value = &boolValueTrue;
writerProperty.valueSize = sizeof(boolValueTrue);
WS_XML_WRITER_PROPERTY writerProperty[2];
writerProperty[0].id = WS_XML_WRITER_PROPERTY_WRITE_DECLARATION;
writerProperty[0].value = &boolValueTrue;
writerProperty[0].valueSize = sizeof(boolValueTrue);
writerProperty[1].id = WS_XML_WRITER_PROPERTY_BUFFER_MAX_SIZE;
ULONG maxBufferSize = 256 * 1024 * 1024UL;
writerProperty[1].value = &maxBufferSize;
writerProperty[1].valueSize = sizeof(maxBufferSize);
void* xml = nullptr;
ULONG xmlLength = 0;
HRESULT ret = WsWriteXmlBufferToBytes(
context->writer,
context->buffer,
nullptr,
&writerProperty,
1,
writerProperty,
sizeof(writerProperty) / sizeof(writerProperty[0]),
context->heap,
&xml,
&xmlLength,