Skip to content
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

Calling MakeRequestAsync with Stream content more then once results in error #1336

Open
karb0f0s opened this issue Jan 5, 2024 · 2 comments · Fixed by #1335 · May be fixed by #1344
Open

Calling MakeRequestAsync with Stream content more then once results in error #1336

karb0f0s opened this issue Jan 5, 2024 · 2 comments · Fixed by #1335 · May be fixed by #1344
Labels
Milestone

Comments

@karb0f0s
Copy link
Member

karb0f0s commented Jan 5, 2024

Calling MakeRequestAsync with Stream content more then once results in error.

MakeRequestAsync generates an HttpContent content each time it's called:

Content = request.ToHttpContent()

Some reqests contain InputFileStream content that forms a multi-part HttpContent with ToMultipartFormDataContent. Unerneath it StreamContent adds to the MultipartFormDataContent which rewinds Stream and next call tries to add content from the end of the Stream, resulting in empty content.

var mediaPartContent = new StreamContent(inputFile.Content)
{
Headers =
{
{"Content-Type", "application/octet-stream"},
{"Content-Disposition", contentDisposition},
},
};

@karb0f0s karb0f0s added this to the Next Major milestone Jan 5, 2024
karb0f0s added a commit that referenced this issue Jan 5, 2024
@karb0f0s karb0f0s linked a pull request Jan 5, 2024 that will close this issue
@tuscen
Copy link
Member

tuscen commented Jan 5, 2024

@karb0f0s Can you make a repro project so I can look into it, please?

@karb0f0s karb0f0s linked a pull request Jan 5, 2024 that will close this issue
@karb0f0s
Copy link
Member Author

karb0f0s commented Jan 6, 2024

@tuscen
https://github.com/karb0f0s/BotClientContentCacheTest

you might need to initialize a submodule first: git submodule init && git submodule update

karb0f0s added a commit that referenced this issue Jan 9, 2024
karb0f0s added a commit that referenced this issue Jan 10, 2024
@karb0f0s karb0f0s linked a pull request Jan 10, 2024 that will close this issue
karb0f0s added a commit that referenced this issue Jan 10, 2024
This reverts commit b12fce6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants