Skip to content
Discussion options

You must be logged in to vote

Reply.From can return any HttpResponseMessage. Refit chooses the stream framing from the response Content-Type alone, so a body with media type text/event-stream is parsed as SSE. Reply.ServerSentEvents(...) and StreamSource can't be combined with a responder, so write the SSE text yourself:

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

            const string sse =
                "data: {\"id\":1,\"name\":\"Ada\"}\n\n" +

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MeikelLP
Comment options

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