HI All,
I am creating a plugin/addon for firefox, which will monitor/log/prevent the url of the files that are being downloaded.
I could successfully implement nsIURIContentListener and register it with nsiuriloader and successfully receiving events like IsPreffered, canHandleContent, doContent for downloads like http://download.sysinternals.com/Files/ ... onitor.zip
However, it does not receive such notification when the header has "Content-Disposition: attachment"
https://developer.mozilla.org/en/Docume ... uided_Tour says that for "Content-Disposition: attachment", nsiuricontentlistener will be bypassed. I have spent quite a lot of time searching for solution on this without success.
Can you anyone please direct me how I can intercept the download through firefox addon/plugin when header has "Content-Disposition: attachment"?
Thank you,
Karan
"Content-Disposition: attachment" and nsIURIContentListener
-
- Posts: 3
- Joined: January 4th, 2011, 10:22 pm
-
- Posts: 1634
- Joined: November 4th, 2002, 8:34 pm
- Location: Kyoto, Nippon (GMT +9)
- Contact:
Re: "Content-Disposition: attachment" and nsIURIContentListe
Maybe it's impossible for an extension, not to mention a plugin.
The flag |forceExternalHandling| is having content listeners skipped. So anyway ExternalHelperAppService will be called.
http://mxr.mozilla.org/mozilla-central/ ... er.cpp#438
The flag |forceExternalHandling| is having content listeners skipped. So anyway ExternalHelperAppService will be called.
http://mxr.mozilla.org/mozilla-central/ ... er.cpp#438
-
- Posts: 3
- Joined: January 4th, 2011, 10:22 pm
Re: "Content-Disposition: attachment" and nsIURIContentListe
Thanks Torisugari,
My requirement is to cancel the download based on few conditions such as domain or file type.
ExternalHelperAppService will pop-up save as dialog. I need to intercept this even before it reaches to ExternalHelperAppService and cancel the request.
Thanks,
Karan
My requirement is to cancel the download based on few conditions such as domain or file type.
ExternalHelperAppService will pop-up save as dialog. I need to intercept this even before it reaches to ExternalHelperAppService and cancel the request.
Thanks,
Karan
-
- Posts: 3
- Joined: January 4th, 2011, 10:22 pm
Re: "Content-Disposition: attachment" and nsIURIContentListe
And also, in nsDocumentOpenInfo::DispatchContent -> nsDocumentOpenInfo tries to get interface for nsiuricontentlistner from the window context. Is it possible to hook my nsiuricontentlistener to it?
~Karan
~Karan
-
- Posts: 3664
- Joined: September 15th, 2010, 9:03 am
Re: "Content-Disposition: attachment" and nsIURIContentListe
Old, but deserves an answer.
Content disposition "attachment" forces the Firefox download file dialog before any content handlers are queries. To prevent this you need to intercept http responses and change the header to inline, using an http-on-examine-response observer. This will cause that response to be routed through the normal content handling. Probably you only want to do this for certain responses relevant to your addon. You should take care that your observer acts very quickly to pass on any responses it isn't interested in since every incoming http message will be stuck in your code until it returns.
Content disposition "attachment" forces the Firefox download file dialog before any content handlers are queries. To prevent this you need to intercept http responses and change the header to inline, using an http-on-examine-response observer. This will cause that response to be routed through the normal content handling. Probably you only want to do this for certain responses relevant to your addon. You should take care that your observer acts very quickly to pass on any responses it isn't interested in since every incoming http message will be stuck in your code until it returns.