Getting all of the output from HttpResponse in a module (Custom Filter?).

J

Josh Naro

I am writing a module that requires the entire output from a web app
to perform its function. So, basically I need to be able to pull the
entire output stream from the Response object. I've tried attaching a
custom filter to Response.Filter, but the custom filter receives the
stream in separate chunks. I need the entire stream at once in order
to convert it to an XmlDocument. Does anyone know of a way to get the
entire output stream from a web app using a module?
 
J

Josh Naro

I am writing a module that requires the entire output from a web app
to perform its function. So, basically I need to be able to pull the
entire output stream from the Response object. I've tried attaching a
custom filter to Response.Filter, but the custom filter receives the
stream in separate chunks. I need the entire stream at once in order
to convert it to an XmlDocument. Does anyone know of a way to get the
entire output stream from a web app using a module?

Well, I managed to figure this one out myself.

Answer:
1. Create a custom filter that makes use of the singleton pattern.
2. Have the filter store each stream as it comes through in a public
variable (i.e. temp += currentStream).
3. Install the filter on BeginRequest of the application from within
a module.
4. Grab your filter on EndRequest of the application from within the
module.
5. Your singleton filter should now have the entire output of the
application in its temp variable.
 
J

Josh Naro

Well, I managed to figure this one out myself.

Answer:
1. Create a custom filter that makes use of the singleton pattern.
2. Have the filter store each stream as it comes through in a public
variable (i.e. temp += currentStream).
3. Install the filter on BeginRequest of the application from within
a module.
4. Grab your filter on EndRequest of the application from within the
module.
5. Your singleton filter should now have the entire output of the
application in its temp variable.

Don't forget to destroy the singleton after use (it'll hang around for
the next request).
Also, you must create a separate singleton for each context you're
working with so that multiple requests are not intermingled.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top