Skip to content

Commit 1b217fd

Browse files
Update HttpRequestMessageFactory to correctly set the Content-Length header
1 parent 89a76da commit 1b217fd

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"core": {
3+
"changeLogMessages": [
4+
"Update HttpRequestMessageFactory to correctly set the Content-Length header"
5+
],
6+
"type": "patch",
7+
"updateMinimum": true
8+
}
9+
}

sdk/src/Core/Amazon.Runtime/Pipeline/HttpHandler/_netstandard/HttpRequestMessageFactory.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -625,13 +625,10 @@ public void WriteToRequestBody(HttpContent requestContent, Stream contentStream,
625625
if ((isChunkedUploadWrapperStreamWithLength || isTrailingHeadersWrapperStreamWithLength || isCompressionWrapperStreamWithLength)
626626
|| (chunkedUploadWrapperStream == null && trailingHeadersWrapperStream == null && compressionWrapperStream == null))
627627
{
628-
long position = 0;
628+
long position;
629629
try
630630
{
631-
if (contentStream.CanSeek)
632-
{
633-
position = contentStream.Position;
634-
}
631+
position = contentStream.Position;
635632
}
636633
catch (NotSupportedException)
637634
{

sdk/test/NetStandard/IntegrationTests/IntegrationTests/S3/PutObjectTests.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ public async Task PutObjectWithoutContentEncoding(bool useChunkEncoding)
189189
/// <summary>
190190
/// Reported in https://github.com/aws/aws-sdk-net/issues/3629
191191
/// </summary>
192-
[Fact]
193-
public async Task TestResetStreamPosition()
192+
[Theory]
193+
[InlineData(true)]
194+
[InlineData(false)]
195+
public async Task TestResetStreamPosition(bool useChunkEncoding)
194196
{
195197
var memoryStream = new MemoryStream();
196198
long offset;
@@ -214,7 +216,7 @@ public async Task TestResetStreamPosition()
214216
AutoResetStreamPosition = false,
215217
AutoCloseStream = !memoryStream.CanSeek,
216218
InputStream = memoryStream.CanSeek ? memoryStream : AmazonS3Util.MakeStreamSeekable(memoryStream),
217-
UseChunkEncoding = false,
219+
UseChunkEncoding = useChunkEncoding,
218220
};
219221

220222
var putResponse = await Client.PutObjectAsync(putRequest);

0 commit comments

Comments
 (0)