You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hope you are well & safe. Also, congrats on your 3.0 release! And thank you for all you do.
I think I may have found a small bug in the library:
voidMain(){vartest=newHttpTest();test.RespondWith("OK");"https://foo.com/upload".PostMultipartAsync( bc =>{bc.AddString("key","value");});test.ShouldHaveCalled("https://foo.com/upload").With(fc =>{varcontent=fc.HttpRequestMessage.ContentasCapturedMultipartContent;content.Parts.Length.Should().Be(1);returntrue;});}
The reason I think CapturedMultipartContent doesn't capture the content is:
The base class MultipartContent is used as a storage container for the items being added:
The HttpRequestMessage is disposed of after the request completes in FlurlRequest. And the content is already gone and cleared by the time we make the assertion.
Thanks for reporting. Ick. I agree, "captured" should imply not clearing that collection. I'll take a crack at fixing. Maybe overriding Dispose is the cleanest way, unless you have other ideas.
...Actually, capturing to a different collection is a little cleaner, and more in line with what CapturedStringContent does. I have no overhead concerns - it's a redundant collection but it references the same object instances as the original.
Hey Todd,
Hope you are well & safe. Also, congrats on your 3.0 release! And thank you for all you do.
I think I may have found a small bug in the library:
The reason I think
CapturedMultipartContent
doesn't capture the content is:The base class
MultipartContent
is used as a storage container for the items being added:Flurl/src/Flurl.Http/Content/CapturedMultipartContent.cs
Line 125 in 1185099
Flurl/src/Flurl.Http/Content/CapturedMultipartContent.cs
Line 22 in 1185099
The
MultipartContent
inSystem.Net.Http
clears the_nestedContent
on.Dispose()
:https://github.com/dotnet/runtime/blob/be9d38c8586af55ac848392fedf0076760e6cccc/src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs#L126-L137
The
HttpRequestMessage
is disposed of after the request completes inFlurlRequest
. And the content is already gone and cleared by the time we make the assertion.Flurl/src/Flurl.Http/FlurlRequest.cs
Line 198 in 1185099
Let me know if you'd like me to create a PR to fix the issue. If performance is a concern, perhaps there could be:
Best regards,
Brian
The text was updated successfully, but these errors were encountered: