Fix AWS S3 upload failure: remove ClearAllHeaders that was wiping SigV4 state
Removing the Fix 1 ClearAllHeaders/ClearAllQueryParams block from all 8 upload entry points. CkRest.AddHeader already overwrites by header name, so the clears were unnecessary; they also wipe the internal state Chilkat's SigV4 signer relies on between requests, which caused AWS to reject every PUT with HTTP 400 MaxMessageLengthExceeded (max 35240 B). Per-step ClearAllQueryParams inside multipart kept (followed immediately by AddQueryParam). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -628,10 +628,6 @@ namespace ANSCENTER
|
|||||||
|
|
||||||
// Auto-prewarm the connection pool so the first N concurrent uploads
|
// Auto-prewarm the connection pool so the first N concurrent uploads
|
||||||
// don't serialize on TLS handshake. No-op if not connected yet.
|
// don't serialize on TLS handshake. No-op if not connected yet.
|
||||||
// Callers wanting a different size can call PrewarmConnectionPool()
|
|
||||||
// directly at any time — this is just a sensible default that keeps
|
|
||||||
// existing LabVIEW callers (which only invoke SetAuthentication via
|
|
||||||
// the C wrapper) warm without any API change on their side.
|
|
||||||
static constexpr int kDefaultPrewarmCount = 8;
|
static constexpr int kDefaultPrewarmCount = 8;
|
||||||
PrewarmConnectionPool(kDefaultPrewarmCount);
|
PrewarmConnectionPool(kDefaultPrewarmCount);
|
||||||
|
|
||||||
@@ -1566,14 +1562,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
// Read the file on each attempt (cheap; keeps the body fresh).
|
// Read the file on each attempt (cheap; keeps the body fresh).
|
||||||
CkFileAccess fac;
|
CkFileAccess fac;
|
||||||
const char* fileContents = fac.readEntireTextFile(textFilePath.c_str(), "utf-8");
|
const char* fileContents = fac.readEntireTextFile(textFilePath.c_str(), "utf-8");
|
||||||
@@ -1665,14 +1653,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
CkBinData binData;
|
CkBinData binData;
|
||||||
if (!binData.LoadFile(dataFilePath.c_str())) {
|
if (!binData.LoadFile(dataFilePath.c_str())) {
|
||||||
lastError = std::string("Failed to load file: ") + binData.lastErrorText();
|
lastError = std::string("Failed to load file: ") + binData.lastErrorText();
|
||||||
@@ -1775,14 +1755,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
CkBinData binData;
|
CkBinData binData;
|
||||||
if (!binData.LoadFile(dataFilePath.c_str())) {
|
if (!binData.LoadFile(dataFilePath.c_str())) {
|
||||||
lastError = std::string("Failed to load file: ") + binData.lastErrorText();
|
lastError = std::string("Failed to load file: ") + binData.lastErrorText();
|
||||||
@@ -1858,14 +1830,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
// Fresh stream per attempt (it holds OS file handle state).
|
// Fresh stream per attempt (it holds OS file handle state).
|
||||||
CkStream fileStream;
|
CkStream fileStream;
|
||||||
fileStream.put_SourceFile(dataFilePath.c_str());
|
fileStream.put_SourceFile(dataFilePath.c_str());
|
||||||
@@ -1979,14 +1943,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
// ---- STEP 1: INITIATE ----
|
// ---- STEP 1: INITIATE ----
|
||||||
conn->rest.ClearAllQueryParams();
|
conn->rest.ClearAllQueryParams();
|
||||||
conn->rest.AddQueryParam("uploads", "");
|
conn->rest.AddQueryParam("uploads", "");
|
||||||
@@ -2203,14 +2159,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
// ---- STEP 1: INITIATE ----
|
// ---- STEP 1: INITIATE ----
|
||||||
conn->rest.ClearAllQueryParams();
|
conn->rest.ClearAllQueryParams();
|
||||||
conn->rest.AddQueryParam("uploads", "");
|
conn->rest.AddQueryParam("uploads", "");
|
||||||
@@ -2370,14 +2318,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
CkBinData binData;
|
CkBinData binData;
|
||||||
CkByteData jpegBytes;
|
CkByteData jpegBytes;
|
||||||
jpegBytes.append2(jpeg_string, static_cast<unsigned long>(bufferLength));
|
jpegBytes.append2(jpeg_string, static_cast<unsigned long>(bufferLength));
|
||||||
@@ -2466,14 +2406,6 @@ namespace ANSCENTER
|
|||||||
conn->rest.put_Host(_fullAWSURL.c_str());
|
conn->rest.put_Host(_fullAWSURL.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix 1: the CkRest inside a pooled S3Connection accumulates
|
|
||||||
// headers and query params across requests. Clear them at the
|
|
||||||
// start of every attempt so a request can't inherit stale
|
|
||||||
// state (e.g. Content-Encoding:gzip) from a prior upload on
|
|
||||||
// this same connection.
|
|
||||||
conn->rest.ClearAllHeaders();
|
|
||||||
conn->rest.ClearAllQueryParams();
|
|
||||||
|
|
||||||
CkBinData binData;
|
CkBinData binData;
|
||||||
CkByteData jpegBytes;
|
CkByteData jpegBytes;
|
||||||
jpegBytes.append2(jpeg_string, static_cast<unsigned long>(bufferLength));
|
jpegBytes.append2(jpeg_string, static_cast<unsigned long>(bufferLength));
|
||||||
|
|||||||
Reference in New Issue
Block a user