I am working on creating a data stream pipeline that is responsible for asynchronously processing HttpRequests sent to the HttpListener . To answer the query, I may have to perform some time-consuming operations, such as analyzing or pulling large amounts of data from the database, thus approaching the data stream. I use HttpListener.GetContextAsync to pass the HttpListenerContext to the first block in the pipeline, which then processes the request and generates a response.
The problem I am facing is that I need to have the original HttpListenerContext object in order to send a response to the client. My first thought was that I could just pass the object through the entire pipeline inside Tuple, but it quickly starts to look and feel really dirty.
Ultimately, from a design point of view, I would like to go through the HttpListenerContext to the pipeline and get a response at the end of the process, which I can then return without having to pass the object through it all as well. Is it possible to associate the final result of the pipeline with the original object that was sent to it?
source share