Skip to content

Leverage IHttpForwarder to implement async request-reply pattern (HTTP 202) #1439

Answered by Tratcher
dinowang asked this question in Q&A
Discussion options

You must be logged in to vote

That's an interesting challenge, I'm not sure if YARP is your best option here. YARP copies the entire request to the destination, waits for the response, and copies the entire response back to the client.

For this flow you'd need to copy the entire request to the destination, return a 202 with a status URI, capture the eventual response in local storage, and then serve it from the status endpoint.

The simplest version of this would copy the request headers to a new fake DefaultHttpContext, buffer the request body and assign it to the fake context, return the 202, and then call IHttpForwarder using the fake context. Correlating the response with the status URI then becomes a matter of boo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by karelz
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