A new solution needs to get the bytes from a huge payload from each HTTP Request and very quickly send HTTP 200 OK as the HTTP Response. (What happens to the payload bytes does not matter for the purpose of the following question).
Question: Which part of ASP.NET or ASP.NET Core give us direct access to the raw HTTP Request payload or HttpContext instance (before any other application-level processing, like deserialization of the payload)?
What about an IHttpHandler (.NET Framework 4.7.2)?
public void IHttpHandler.ProcessRequest (System.Web.HttpContext context);
To me is not clear what is your goal.
But with info provided I thing if:
1) You are receiving multiple requests;
2) You are getting requests and relaying to another place;
In both cases your server should return HTTP 200 OK , or any other HTTP code
By link provided, you infer on Content Response and have access to many other properties of Context.
On the other hand if your scenario is like a Relay Request, here you have to use HttpWebRequest then on HttpWebResponse you can get all Stream and many more properties.
Thank very much, jzero, for your response. My goal is to respond HTTP 200 OK as quickly as possible regardless the size of the HTTP Request payload. The bytes of the HTTP Request payload might be stored for later out-of-band processing. The quick HTTP 200
OK response is not related at all to the outcome of such out-of-band processing.
Question: Which part of ASP.NET or ASP.NET Core give us direct access to the raw HTTP Request payload or HttpContext instance (before any other application-level processing, like deserialization of the payload)?
The Http Pipeline.
ASP.NET is very mature and there is a lot of openly published documentation on the subject. In ASP.NET the Global.asax has access to the request through
various event handlers like the
Application_BeginRequest handler
The IHttpHandlers allows you to write custom handler. Then register the handlers in the web.config.
Thank you very much, jzero, for your response. There is no 'page' in the initial posted scenario, so your point 3) makes no sense. But, point 2) is a very good point that is currently in evaluation already. The initial question is all about your point 1);
how to get direct access to the raw HTTP Request payload before any processing on that payload.
Member
1 Points
4 Posts
Direct access to raw HTTP Request payload
Jan 29, 2019 06:54 PM|Marco Dorantes|LINK
Hi, all.
A new solution needs to get the bytes from a huge payload from each HTTP Request and very quickly send HTTP 200 OK as the HTTP Response. (What happens to the payload bytes does not matter for the purpose of the following question).
Question: Which part of ASP.NET or ASP.NET Core give us direct access to the raw HTTP Request payload or HttpContext instance (before any other application-level processing, like deserialization of the payload)?
What about an IHttpHandler (.NET Framework 4.7.2)?
public void IHttpHandler.ProcessRequest (System.Web.HttpContext context);
https://docs.microsoft.com/en-us/dotnet/api/system.web.ihttphandler.processrequest?view=netframework-4.7.2#System_Web_IHttpHandler_ProcessRequest_System_Web_HttpContext_
Thank you very much in advance for any help.
Member
749 Points
527 Posts
Re: Direct access to raw HTTP Request payload
Jan 29, 2019 11:03 PM|jzero|LINK
To me is not clear what is your goal.
But with info provided I thing if:
1) You are receiving multiple requests;
2) You are getting requests and relaying to another place;
In both cases your server should return HTTP 200 OK , or any other HTTP code
By link provided, you infer on Content Response and have access to many other properties of Context.
On the other hand if your scenario is like a Relay Request, here you have to use HttpWebRequest then on HttpWebResponse you can get all Stream and many more properties.
This all I can comment about for now
Member
1 Points
4 Posts
Re: Direct access to raw HTTP Request payload
Jan 29, 2019 11:14 PM|Marco Dorantes|LINK
Thank very much, jzero, for your response. My goal is to respond HTTP 200 OK as quickly as possible regardless the size of the HTTP Request payload. The bytes of the HTTP Request payload might be stored for later out-of-band processing. The quick HTTP 200 OK response is not related at all to the outcome of such out-of-band processing.
Member
749 Points
527 Posts
Re: Direct access to raw HTTP Request payload
Jan 30, 2019 07:58 PM|jzero|LINK
It seems we are not going anywhere..... But a short answer could be:
1) Get request;
2) Start a Background Task;
3) Return a page with "Hello World"
Is this quickly enough?
All-Star
43731 Points
18710 Posts
Re: Direct access to raw HTTP Request payload
Jan 30, 2019 09:50 PM|mgebhard|LINK
The Http Pipeline.
ASP.NET is very mature and there is a lot of openly published documentation on the subject. In ASP.NET the Global.asax has access to the request through various event handlers like the Application_BeginRequest handler
The IHttpHandlers allows you to write custom handler. Then register the handlers in the web.config.
https://docs.microsoft.com/en-us/dotnet/api/system.web.ihttphandler.processrequest?view=netframework-4.7.2
https://support.microsoft.com/en-us/help/308001/how-to-create-an-asp-net-http-handler-by-using-visual-c-net
OWIN (Open Web Interface for .NET) is newer ASP.NET interface for developing Http pipeline services for .NET
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/owin?view=aspnetcore-2.2
ASP.NET Core has excellent docs. Middleware is how to access the HTTP pipeline, See the Core Fundamental docs.
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-2.2
Keep in mind, ASp.NET Core designed for speed. The Request is read once so you need to write a little code to bypass this feature.
https://stackoverflow.com/questions/40494913/how-to-read-request-body-in-a-asp-net-core-webapi-controller
Member
1 Points
4 Posts
Re: Direct access to raw HTTP Request payload
Jan 31, 2019 02:37 PM|Marco Dorantes|LINK
Thank you very much, jzero, for your response. There is no 'page' in the initial posted scenario, so your point 3) makes no sense. But, point 2) is a very good point that is currently in evaluation already. The initial question is all about your point 1); how to get direct access to the raw HTTP Request payload before any processing on that payload.
Best regards.
Member
1 Points
4 Posts
Re: Direct access to raw HTTP Request payload
Jan 31, 2019 02:43 PM|Marco Dorantes|LINK
Thank you very much, mgebhard, for your response. I'll take a look at those options.
Best regards.