diff --git a/mozilla/modules/plugin/base/public/npapi.h b/mozilla/modules/plugin/base/public/npapi.h index 609211238b8..2c66c080edb 100644 --- a/mozilla/modules/plugin/base/public/npapi.h +++ b/mozilla/modules/plugin/base/public/npapi.h @@ -37,7 +37,7 @@ /* - * npapi.h $Revision: 3.40.4.1 $ + * npapi.h $Revision: 3.40.4.1.4.1 $ * Netscape client plug-in API spec */ @@ -125,7 +125,7 @@ /*----------------------------------------------------------------------*/ #define NP_VERSION_MAJOR 0 -#define NP_VERSION_MINOR 16 +#define NP_VERSION_MINOR 17 /* The OS/2 version of Netscape uses RC_DATA to define the @@ -255,6 +255,16 @@ typedef struct _NPStream uint32 end; uint32 lastmodified; void* notifyData; + const char* headers; /* Response headers from host. + * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS. + * Used for HTTP only; NULL for non-HTTP. + * Available from NPP_NewStream onwards. + * Plugin should copy this data before storing it. + * Includes HTTP status line and all headers, + * preferably verbatim as received from server, + * headers formatted as in HTTP ("Header: Value"), + * and newlines (\n, NOT \r\n) separating lines. + * Terminated by \n\0 (NOT \n\n\0). */ } NPStream; @@ -614,13 +624,17 @@ enum NPEventType { /* * Version feature information */ -#define NPVERS_HAS_STREAMOUTPUT 8 -#define NPVERS_HAS_NOTIFICATION 9 -#define NPVERS_HAS_LIVECONNECT 9 -#define NPVERS_WIN16_HAS_LIVECONNECT 9 -#define NPVERS_68K_HAS_LIVECONNECT 11 -#define NPVERS_HAS_WINDOWLESS 11 -#define NPVERS_HAS_XPCONNECT_SCRIPTING 13 +#define NPVERS_HAS_STREAMOUTPUT 8 +#define NPVERS_HAS_NOTIFICATION 9 +#define NPVERS_HAS_LIVECONNECT 9 +#define NPVERS_WIN16_HAS_LIVECONNECT 9 +#define NPVERS_68K_HAS_LIVECONNECT 11 +#define NPVERS_HAS_WINDOWLESS 11 +#define NPVERS_HAS_XPCONNECT_SCRIPTING 13 +#define NPVERS_HAS_NPRUNTIME_SCRIPTING 14 +#define NPVERS_HAS_FORM_VALUES 15 +#define NPVERS_HAS_POPUPS_ENABLED_STATE 16 +#define NPVERS_HAS_RESPONSE_HEADERS 17 /*----------------------------------------------------------------------*/ /* Function Prototypes */ diff --git a/mozilla/modules/plugin/base/public/nsIHTTPHeaderListener.idl b/mozilla/modules/plugin/base/public/nsIHTTPHeaderListener.idl index d65042b62df..15f75de8c20 100644 --- a/mozilla/modules/plugin/base/public/nsIHTTPHeaderListener.idl +++ b/mozilla/modules/plugin/base/public/nsIHTTPHeaderListener.idl @@ -60,3 +60,14 @@ interface nsIHTTPHeaderListener : nsISupports */ void newResponseHeader(in string headerName, in string headerValue); }; + +[scriptable, uuid(cf44a295-7310-4330-84c6-600039a155ef)] +interface nsIHTTPHeaderListener_MOZILLA_1_8_BRANCH : nsIHTTPHeaderListener +{ + /** + * Called once for the HTTP Response status line. + * Value does NOT include a terminating newline. + * NOTE: You must copy this value. + */ + void statusLine(in string line); +}; diff --git a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp index daf7215ee78..1cc3cb62f20 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp @@ -87,8 +87,9 @@ static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID); /////////////////////////////////////////////////////////////////////////////// // ns4xPluginStreamListener Methods -NS_IMPL_ISUPPORTS2(ns4xPluginStreamListener, nsIPluginStreamListener, - nsITimerCallback) +NS_IMPL_ISUPPORTS4(ns4xPluginStreamListener, nsIPluginStreamListener, + nsITimerCallback, nsIHTTPHeaderListener, + nsIHTTPHeaderListener_MOZILLA_1_8_BRANCH) /////////////////////////////////////////////////////////////////////////////// @@ -105,7 +106,8 @@ ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst, mStreamStarted(PR_FALSE), mStreamCleanedUp(PR_FALSE), mCallNotify(PR_FALSE), - mIsSuspended(PR_FALSE) + mIsSuspended(PR_FALSE), + mResponseHeaderBuf(nsnull) { // Initialize the 4.x interface structure memset(&mNPStream, 0, sizeof(mNPStream)); @@ -152,6 +154,9 @@ ns4xPluginStreamListener::~ns4xPluginStreamListener(void) if (mNotifyURL) PL_strfree(mNotifyURL); + + if (mResponseHeaderBuf) + PL_strfree(mResponseHeaderBuf); } /////////////////////////////////////////////////////////////////////////////// @@ -268,6 +273,11 @@ ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo) pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified)); pluginInfo->IsSeekable(&seekable); pluginInfo->GetContentType(&contentType); + + if (!mResponseHeaders.IsEmpty()) { + mResponseHeaderBuf = PL_strdup(mResponseHeaders.get()); + mNPStream.headers = mResponseHeaderBuf; + } mStreamInfo = pluginInfo; @@ -753,6 +763,27 @@ ns4xPluginStreamListener::Notify(nsITimer *aTimer) return NS_OK; } +/////////////////////////////////////////////////////////////////////////////// +NS_IMETHODIMP +ns4xPluginStreamListener::StatusLine(const char* line) +{ + mResponseHeaders.Append(line); + mResponseHeaders.Append('\n'); + return NS_OK; +} + +/////////////////////////////////////////////////////////////////////////////// +NS_IMETHODIMP +ns4xPluginStreamListener::NewResponseHeader(const char* headerName, + const char* headerValue) +{ + mResponseHeaders.Append(headerName); + mResponseHeaders.Append(": "); + mResponseHeaders.Append(headerValue); + mResponseHeaders.Append('\n'); + return NS_OK; +} + /////////////////////////////////////////////////////////////////////////////// nsInstanceStream::nsInstanceStream() { diff --git a/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h b/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h index 71c10f4ead0..daf10643418 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h +++ b/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h @@ -40,6 +40,7 @@ #include "nsIPluginStreamListener.h" #include "nsIPluginStreamInfo.h" +#include "nsIHTTPHeaderListener.h" #include "nsIRequest.h" #include "nsITimer.h" #include "nsCOMPtr.h" @@ -50,7 +51,8 @@ class ns4xPluginInstance; class nsI4xPluginStreamInfo; class ns4xPluginStreamListener : public nsIPluginStreamListener, - public nsITimerCallback + public nsITimerCallback, + public nsIHTTPHeaderListener_MOZILLA_1_8_BRANCH { public: NS_DECL_ISUPPORTS @@ -66,6 +68,10 @@ public: NS_DECL_NSITIMERCALLBACK + // from nsIHTTPHeaderListener: + NS_IMETHOD StatusLine(const char* line); + NS_IMETHOD NewResponseHeader(const char* headerName, const char* headerValue); + // ns4xPluginStreamListener specific methods: ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData, const char* aURL); @@ -95,6 +101,8 @@ protected: PRPackedBool mStreamCleanedUp; PRPackedBool mCallNotify; PRPackedBool mIsSuspended; + nsCString mResponseHeaders; + char* mResponseHeaderBuf; nsCOMPtr mDataPumpTimer; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index aba151e6e64..76b385fd189 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -61,6 +61,7 @@ #include "nsIObserverService.h" #include "nsIHttpProtocolHandler.h" #include "nsIHttpChannel.h" +#include "nsIHttpChannelInternal.h" #include "nsIUploadChannel.h" #include "nsIByteRangeRequest.h" #include "nsIStreamListener.h" @@ -87,6 +88,7 @@ #include "nsObsoleteModuleLoading.h" #include "nsIComponentRegistrar.h" #include "nsPluginLogging.h" +#include "nsPrintfCString.h" // Friggin' X11 has to "#define None". Lame! #ifdef None @@ -2407,6 +2409,42 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, * called, all the headers have been read. */ if (httpChannel) { + // Reassemble the HTTP response status line and provide it to our + // listener. Would be nice if we could get the raw status line, + // but nsIHttpChannel doesn't currently provide that. + nsCOMPtr listener = + do_QueryInterface(mPStreamListener); + if (listener) { + // Status code: required; the status line isn't useful without it. + PRUint32 statusNum; + if (NS_SUCCEEDED(httpChannel->GetResponseStatus(&statusNum)) && + statusNum < 1000) { + // HTTP version: provide if available. Defaults to empty string. + nsCString ver; + nsCOMPtr httpChannelInternal = + do_QueryInterface(channel); + if (httpChannelInternal) { + PRUint32 major, minor; + if (NS_SUCCEEDED(httpChannelInternal->GetResponseVersion(&major, + &minor))) { + ver = nsPrintfCString("/%lu.%lu", major, minor); + } + } + + // Status text: provide if available. Defaults to "OK". + nsCString statusText; + if (!NS_SUCCEEDED(httpChannel->GetResponseStatusText(statusText))) { + statusText = "OK"; + } + + // Assemble everything and pass to listener. + nsPrintfCString status(100, "HTTP%s %lu %s", ver.get(), statusNum, + statusText.get()); + listener->StatusLine(status.get()); + } + } + + // Also provide all HTTP response headers to our listener. httpChannel->VisitResponseHeaders(this); PRBool bSeekable = PR_FALSE;