Skip to content
Discussion options

You must be logged in to vote

Turn off StubHttp's body capture and read the parts inside Reply.From, while the request's still alive:

var parts = new Dictionary<string, string>();
var http = new StubHttp
{
    { Route.Post("/upload"), Reply.From(async request =>
        {
            var multipart = (MultipartFormDataContent)request.Content!;
            foreach (var part in multipart)
                parts[part.Headers.ContentDisposition!.Name!] = await part.ReadAsStringAsync();
            return new HttpResponseMessage(HttpStatusCode.OK);
        }) },
};
http.RequestCapture = RequestCapture.None;

var api = http.CreateClient<IUploadApi>("https://api.test");
await api.Upload(new StreamPart(stream, "a.txt", "text/pl…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MeikelLP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants