Re: [flexcoders] Capturing URL Requests in AIR application (HTML/HTMLLoader/HTMLHost)

2009-08-19 Thread Wesley Acheson
Is it not the responseHeaders that you need? on the following object
http://livedocs.adobe.com/flex/3/langref/flash/events/HTTPStatusEvent.html

Regards,

Wesley Acheson

On Wed, Aug 19, 2009 at 12:54 PM, Barry Evans  wrote:

> Hi,
>
> This post is quite lengthy, but I really need to explain in detail what it
> is I'm trying to achieve here.
>
> I am developing an AIR application that has an mx.controls.HTML component
> as the only child; in essence the application is a custom web browser in
> AIR.
>
> I have created a custom HTMLHost component that extends the
> flash.html.HTMLHost class per the Adobe documentation, so that my
> application can intercept particular JavaScript calls; i.e.
> (AS)createWindow() -> (JS)window.open().
>
> The main HTML component has its htmlHost property set to an instance of
> this CustomHTMLHost class, and every new window that is created via the
> createWindow() method also has its htmlHost set to an instance of the
> CustomHTMLHost class.
>
> In my CustomHTMLHost class, I also override the
> updateLocation(locationURL:String) method, enabling me to inspect the new
> URL that is being set on either the main HTML component, or any popup
> windows that are created.
>
> The web application I am loading into the main HTML component allows users
> to export reports in a number of formats (HTML, PDF, XLS, CSV, TXT) which
> can either be opened or downloaded when using a conventional browser
> (IE/FF/Safari).
>
> When the user exports a report, a popup window is displayed (which works
> fine with my application because of the overridden createWindow() method in
> the CutsomHTMLHost class).
> After the user clicks the final "Export" button on a PDF/HTML/TXT export,
> everything works fine and the report results are displayed as the AIR
> runtime can handle these files.
>
> However when the user exports to XLS/CSV nothing happens, which is expected
> because the AIR runtime does not support those file types.
> I intend to create a file download manager to handle this so that the user
> can just save the files to their local file system, and this is where I'm
> hitting a brick wall.
>
> I am able to capture the URL that is being requested to get these latter
> export types from the overridden updateLocation(locationURL:String) method
> in the CustomHTMLHost class, but the URL alone is not enough information for
> the AIR application to send to the web application that provides the report
> exporting functionality.
>
> I need to get access to the rest of the header information (such as POST
> variables, and also the cookie information) that is sent in the HTTP request
> when the final "Export" button is clicked by the user to ensure I am getting
> a valid response from the web application.
>
> So, to finally get to my main question...  is there any way to intercept
> the URLRequests that are created and invoked from a HTML/HTMLHost component?
>
> What I really want to be able to do is to inspect the HTTP responses, so
> that I can determine content of the HTTP response i.e.
>  Content-Disposition: filename*=Report.xls;
>  Content-Type: application/vnd.ms-excel; charset=UnicodeLittle
>
> With this information I can let my AIR application display a save file
> dialog or something along those lines.
>
> Sorry for the long post, and any help would be appreciated as this is a
> critical part of my AIR application, and I REALLY need to figure this out.
>
> I understand that the approach I am proposing may not even be possible, as
> I have been doing a number of things to try and solve it.
> One of which was extending the HTMLLoader class and overriding the
> load(urlRequestToLoad:URLRequest) method to I could intercept all
> URLRequests, but I couldn't even get the HTML component that used this class
> as its htmlLoader property to load any HTML content.
>
> Thanks in advance,
>
> Barry
>
>
>
> 
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>


[flexcoders] Capturing URL Requests in AIR application (HTML/HTMLLoader/HTMLHost)

2009-08-19 Thread Barry Evans
Hi,

This post is quite lengthy, but I really need to explain in detail what it is 
I'm trying to achieve here.

I am developing an AIR application that has an mx.controls.HTML component as 
the only child; in essence the application is a custom web browser in AIR.

I have created a custom HTMLHost component that extends the flash.html.HTMLHost 
class per the Adobe documentation, so that my application can intercept 
particular JavaScript calls; i.e. (AS)createWindow() -> (JS)window.open().

The main HTML component has its htmlHost property set to an instance of this 
CustomHTMLHost class, and every new window that is created via the 
createWindow() method also has its htmlHost set to an instance of the 
CustomHTMLHost class.

In my CustomHTMLHost class, I also override the 
updateLocation(locationURL:String) method, enabling me to inspect the new URL 
that is being set on either the main HTML component, or any popup windows that 
are created.

The web application I am loading into the main HTML component allows users to 
export reports in a number of formats (HTML, PDF, XLS, CSV, TXT) which can 
either be opened or downloaded when using a conventional browser (IE/FF/Safari).

When the user exports a report, a popup window is displayed (which works fine 
with my application because of the overridden createWindow() method in the 
CutsomHTMLHost class).
After the user clicks the final "Export" button on a PDF/HTML/TXT export, 
everything works fine and the report results are displayed as the AIR runtime 
can handle these files.

However when the user exports to XLS/CSV nothing happens, which is expected 
because the AIR runtime does not support those file types.
I intend to create a file download manager to handle this so that the user can 
just save the files to their local file system, and this is where I'm hitting a 
brick wall.

I am able to capture the URL that is being requested to get these latter export 
types from the overridden updateLocation(locationURL:String) method in the 
CustomHTMLHost class, but the URL alone is not enough information for the AIR 
application to send to the web application that provides the report exporting 
functionality.

I need to get access to the rest of the header information (such as POST 
variables, and also the cookie information) that is sent in the HTTP request 
when the final "Export" button is clicked by the user to ensure I am getting a 
valid response from the web application.

So, to finally get to my main question...  is there any way to intercept the 
URLRequests that are created and invoked from a HTML/HTMLHost component?

What I really want to be able to do is to inspect the HTTP responses, so that I 
can determine content of the HTTP response i.e. 
  Content-Disposition: filename*=Report.xls;
  Content-Type: application/vnd.ms-excel; charset=UnicodeLittle

With this information I can let my AIR application display a save file dialog 
or something along those lines.

Sorry for the long post, and any help would be appreciated as this is a 
critical part of my AIR application, and I REALLY need to figure this out.

I understand that the approach I am proposing may not even be possible, as I 
have been doing a number of things to try and solve it.
One of which was extending the HTMLLoader class and overriding the 
load(urlRequestToLoad:URLRequest) method to I could intercept all URLRequests, 
but I couldn't even get the HTML component that used this class as its 
htmlLoader property to load any HTML content.

Thanks in advance,

Barry