Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How???

Reply
Thread Tools

Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How???

 
 
Brian Birtle
Guest
Posts: n/a
 
      10-16-2003
John,
Thanks again for your post.

I saw the IHttpAsyncHandler class back when I was researching the
problem and thought "Eureka!" But when I looked into it it seems like
the purpose is actually to handle certain cases where the HTTP
*response* (not request) should be made based on external events -
like bytes read from a slow data stream which you've connected to from
the server... short answer is it doesn't seem to do what I need.

Unforunately I've been too busy to build a test case, but I suspect
since it's also based on the HttpContext/HttpRequest framework the
behavior will be the same as an HttpHandler, which has the same
thread-blocking problem.

Any other ideas?

- Brian

"John Saunders" <john.saunders at surfcontrol.com> wrote in message news:<#(E-Mail Removed)>...
> "Brian Birtle" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > John, Thanks for responding.
> >
> > I should clarify that my question is not about creating a progress
> > meter per se as I have already successfully created one using ASP
> > classic. My question is, generally speaking, why do
> > Request.BinaryRead, Request.InputStream, and Request.Filter thread
> > block and is there a workaround?

>
> Yes. The workaround to synchronous behavior is to use an asynchronous
> handler. See IHttpAsyncHandler in the documentation.
>
> Even if you can find a way to not block until the entire request has been
> read, I hope you realize that there is still no correspondence between the
> time you receive a byte and the time the client sent it, except that you can
> be certain the byte was sent before it was received. As an example, you
> might read the first ten bytes very soon after the client sent them, but the
> next ten bytes might be received after the client has finished sending the
> entire request. If this is not acceptible, you should not be using HTTP.
>
> >
> > Here is some example code to show what I'm talking about (put in your
> > global.asax or class that derives from HttpApplication):
> >
> > ... On_BeginRequest(...)
> > {
> > ////This line gets executed right when the HTTP connection is
> > // opened (before even any of the HTTP request is read):
> > Application["UploadState"] = "started";
> > ...

>
> I hope you meant Session and not Application, unless you can ensure that
> there will never be more than one request at a time.

 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      10-16-2003
"Brian Birtle" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> John,
> Thanks again for your post.
>
> I saw the IHttpAsyncHandler class back when I was researching the
> problem and thought "Eureka!" But when I looked into it it seems like
> the purpose is actually to handle certain cases where the HTTP
> *response* (not request) should be made based on external events -
> like bytes read from a slow data stream which you've connected to from
> the server... short answer is it doesn't seem to do what I need.
>
> Unforunately I've been too busy to build a test case, but I suspect
> since it's also based on the HttpContext/HttpRequest framework the
> behavior will be the same as an HttpHandler, which has the same
> thread-blocking problem.
>
> Any other ideas?


Well, I know it's not _just_ a matter of the response being asynchronous.
The BeginProcessRequest method can initiate a chain of asynchronous events,
so at least the processing of the request can be done in parallel.

The question will be: is it the case that BeginProcessRequest is only called
after the entire request has been read in?
--
John Saunders
Internet Engineer
http://www.velocityreviews.com/forums/(E-Mail Removed)


> "John Saunders" <john.saunders at surfcontrol.com> wrote in message

news:<#(E-Mail Removed)>...
> > "Brian Birtle" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) om...
> > > John, Thanks for responding.
> > >
> > > I should clarify that my question is not about creating a progress
> > > meter per se as I have already successfully created one using ASP
> > > classic. My question is, generally speaking, why do
> > > Request.BinaryRead, Request.InputStream, and Request.Filter thread
> > > block and is there a workaround?

> >
> > Yes. The workaround to synchronous behavior is to use an asynchronous
> > handler. See IHttpAsyncHandler in the documentation.
> >
> > Even if you can find a way to not block until the entire request has

been
> > read, I hope you realize that there is still no correspondence between

the
> > time you receive a byte and the time the client sent it, except that you

can
> > be certain the byte was sent before it was received. As an example, you
> > might read the first ten bytes very soon after the client sent them, but

the
> > next ten bytes might be received after the client has finished sending

the
> > entire request. If this is not acceptible, you should not be using HTTP.
> >
> > >
> > > Here is some example code to show what I'm talking about (put in your
> > > global.asax or class that derives from HttpApplication):
> > >
> > > ... On_BeginRequest(...)
> > > {
> > > ////This line gets executed right when the HTTP connection is
> > > // opened (before even any of the HTTP request is read):
> > > Application["UploadState"] = "started";
> > > ...

> >
> > I hope you meant Session and not Application, unless you can ensure that
> > there will never be more than one request at a time.



 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      10-16-2003
"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:%23OdLK2%(E-Mail Removed)...
> "Brian Birtle" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > John,
> > Thanks again for your post.
> >
> > I saw the IHttpAsyncHandler class back when I was researching the
> > problem and thought "Eureka!" But when I looked into it it seems like
> > the purpose is actually to handle certain cases where the HTTP
> > *response* (not request) should be made based on external events -
> > like bytes read from a slow data stream which you've connected to from
> > the server... short answer is it doesn't seem to do what I need.
> >
> > Unforunately I've been too busy to build a test case, but I suspect
> > since it's also based on the HttpContext/HttpRequest framework the
> > behavior will be the same as an HttpHandler, which has the same
> > thread-blocking problem.
> >
> > Any other ideas?

>
> Well, I know it's not _just_ a matter of the response being asynchronous.
> The BeginProcessRequest method can initiate a chain of asynchronous

events,
> so at least the processing of the request can be done in parallel.
>
> The question will be: is it the case that BeginProcessRequest is only

called
> after the entire request has been read in?


P.S. So you should go try the above and get back to us.

If BeginProcessRequest doesn't happen until the entire request has been read
in, then you're SOL as far as standard ASP.NET. This would leave you needing
to implement your own host for ASP.NET. See the Cassini web server at
http://asp.net for an example of this.
--
John Saunders
Internet Engineer
(E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing Request.Browser throws an exception germ ASP .Net 1 07-05-2007 11:12 PM
Accessing the HTTP Request sent to legacy ASP page in .Net C# COM omantawy@gmail.com ASP .Net 1 09-21-2006 08:57 PM
Session or Request.Form for accessing Sensitive data Microsoft ASP .Net 0 05-19-2006 10:50 PM
Accessing objects in request through <c:out jstl tags - Urgent KK Java 1 08-27-2003 01:02 PM
Accessing page request / server variables in a class file. jgamble@noreply.screenpages.com ASP .Net 1 07-09-2003 11:55 AM



Advertisments