Chunked large JSON POST using .NET HttpClient?

懵懂的女人 提交于 2021-02-08 06:41:30

问题



I am sending data for up to 10K users in JSON format to a http endpoint in a .NET Core MVC server app. The JSON is built slowly user by user and is custom (JSON.NET just isn't usable for me). I use a HttpClient and I basically want to send the JSON chunk by chunk so I don't have to accumulate it all at once and sit with a multi-megabyte string in memory for each request, hurting my large object heap. I cannot find and equivalent for HttpWebRequest.GetRequestStream that was used earlier.

StreamContent doesn't seem to fit the bill, I even found PushStreamContent, PipeStream etc. but I don't see a way how to do it, haven't found any answers on SO... Last option I can think of seems to inherit from Stream and implement it myself, but there must be a better way, many people must've encountered this problem.
Any advice?

来源:https://stackoverflow.com/questions/57727883/chunked-large-json-post-using-net-httpclient

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!