diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp index c3f5e5158da..3c6575bbf7d 100644 --- a/uriloader/base/nsURILoader.cpp +++ b/uriloader/base/nsURILoader.cpp @@ -427,17 +427,13 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * // All attempts to dispatch this content have failed. Just pass it off to // the helper app service. - nsCOMPtr uri; - PRBool abortProcess = PR_FALSE; - aChannel->GetURI(getter_AddRefs(uri)); nsCOMPtr helperAppService = do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &rv); if (helperAppService) { rv = helperAppService->DoContent(contentType.get(), - uri, + request, m_originalContext, - &abortProcess, getter_AddRefs(contentStreamListener)); if (NS_SUCCEEDED(rv) && contentStreamListener) { m_targetStreamListener = contentStreamListener; diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 48bd74aceaf..987ee47f8ff 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -42,6 +42,7 @@ #include "nsIWebProgressListener.h" #include "nsIDownload.h" #include "nsReadableUtils.h" +#include "nsIRequest.h" // used to manage our in memory data source of helper applications #include "nsRDFCID.h" @@ -273,8 +274,10 @@ NS_IMETHODIMP nsExternalHelperAppService::CanHandleContent(const char *aMimeCont return NS_OK; } -NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType, nsIURI *aURI, nsISupports *aWindowContext, - PRBool *aAbortProcess, nsIStreamListener ** aStreamListener) +NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType, + nsIRequest *aRequest, + nsISupports *aWindowContext, + nsIStreamListener ** aStreamListener) { nsCOMPtr mimeInfo; nsCAutoString fileExtension, query; @@ -282,7 +285,23 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType // (1) Try to find a mime object by looking the mime type GetFromMIMEType(aMimeContentType, getter_AddRefs(mimeInfo)); - nsCOMPtr url = do_QueryInterface(aURI); + // Get some stuff we will need later + nsCOMPtr channel = do_QueryInterface(aRequest); + + nsCOMPtr url; + PRBool methodIsPost = PR_FALSE; + if (channel) { + nsCOMPtr uri; + channel->GetURI(getter_AddRefs(uri)); + url = do_QueryInterface(uri); + + nsCOMPtr httpChan = do_QueryInterface(channel); + if (httpChan) { + nsCAutoString requestMethod; + httpChan->GetRequestMethod(requestMethod); + methodIsPost = requestMethod.Equals("POST"); + } + } if (!mimeInfo) { @@ -294,8 +313,9 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType // If so, then the extension in the URL doesn't tell us // anything about the content of the data, so don't try // to find a handler based on that. + // Same if it's the result of POSTed data url->GetQuery(query); - if (query.IsEmpty()) { + if (query.IsEmpty() && !methodIsPost) { url->GetFileExtension(fileExtension); GetFromExtension(fileExtension.get(), getter_AddRefs(mimeInfo)); // only over write mimeInfo if we got a non-null mime info object. @@ -376,10 +396,9 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const char *aMimeContentType // should be the primary extension once we are doen. // Ignore URL extension if data is output from a cgi script. if (fileExtension.IsEmpty()) { - nsCOMPtr url = do_QueryInterface(aURI); if (url) { url->GetQuery(query); - if (query.IsEmpty()) { + if (query.IsEmpty() && !methodIsPost) { url->GetFileExtension(fileExtension); } } diff --git a/uriloader/exthandler/nsIExternalHelperAppService.idl b/uriloader/exthandler/nsIExternalHelperAppService.idl index 99d077e2bb5..b9e8aa85406 100644 --- a/uriloader/exthandler/nsIExternalHelperAppService.idl +++ b/uriloader/exthandler/nsIExternalHelperAppService.idl @@ -27,6 +27,7 @@ #include "nsISupports.idl" interface nsIURI; +interface nsIRequest; interface nsIStreamListener; interface nsIFile; interface nsIMIMEInfo; @@ -47,14 +48,12 @@ interface nsIExternalHelperAppService : nsISupports // into the returned stream listener. When the OnStopRequest is issued, the stream listener implementation // will launch the helper app with this data. // aMimeContentType --> the content type of the incoming data - // aURI --> the URI corresponding to the incoming data + // aRequest --> the request corresponding to the incoming data // aWindowContext --> use GetInterface to retrieve properties like the dom window or parent window... // the service might need this in order to bring up dialogs. - // aAbortProcess --> set to TRUE by the helper service if the caller should just forget about loading the document - // (typically this occurs if the helper app just wants the URI to run and not the data) // returns a nsIStreamListener which the caller should pump the data into. - nsIStreamListener doContent (in string aMimeContentType, in nsIURI aURI, - in nsISupports aWindowContext, out boolean aAbortProcess); + nsIStreamListener doContent (in string aMimeContentType, in nsIRequest aRequest, + in nsISupports aWindowContext); // applyDecodingForType: returns true if this type is to be decoded // prior to saving or passing off to helper apps,