-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Multipart request sends and then throws NRE #2188
Comments
After debugging with dnspy I can see what's happening - it seems like RequestContent tries to dispose its content after it has been disposed already by HttpClient which I think it does after sending request. When disposing MultipartContent it does this (decompiled): protected override void Dispose(bool disposing)
{
if (disposing)
{
foreach (HttpContent httpContent in this.nested_content)
{
httpContent.Dispose();
}
this.nested_content = null;
}
base.Dispose(disposing);
} So second call to that function would throw NRE while trying to enumerate |
I encountered the same problem and resolved it by rolling back to version 110.0.0. |
It's weird as the content class checks if it is disposing or has been disposed, and should not dispose itself when any of those is true. |
Describe the bug
I'm trying to send request from Unity using RestSharp 110.2.0 - sending normal request works but when I make multipart request with attachment it sends requests and then immediately throws NullReferenceException from
System.Net.Http.MultipartContent.Dispose
. I tried attaching file using stream creating callback and file name with same results. This is an attempt to send discord webhook request with attachment and message actually appears on the server despite NRE after sending.To Reproduce
Sending request with this code succeeds but throws exception:
Expected behavior
Function successfully returning response after request has been sent.
Stack trace
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: