diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 4c9b02f67e3..ce69216997d 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -84,6 +84,24 @@ static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); static NS_DEFINE_CID(kDocumentCharsetInfoCID, NS_DOCUMENTCHARSETINFO_CID); static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID); +// +// Local function prototypes +// + +/** + + * Used in AddHeadersToChannel + + */ + +static NS_METHOD AHTC_WriteFunc(nsIInputStream* in, + void* closure, + const char* fromRawSegment, + PRUint32 toOffset, + PRUint32 count, + PRUint32 *writeCount); + + //***************************************************************************** //*** nsDocShell: Object Management //***************************************************************************** @@ -282,7 +300,8 @@ nsDocShell::LoadURI(nsIURI* aURI, nsIDocShellLoadInfo* aLoadInfo) if (shEntry) { rv = LoadHistoryEntry(shEntry, loadType); } else { - rv = InternalLoad(aURI, referrer, owner, inheritOwner, nsnull, nsnull, loadType, nsnull); + rv = InternalLoad(aURI, referrer, owner, inheritOwner, nsnull, nsnull, + nsnull, loadType, nsnull); } return rv; @@ -1306,7 +1325,7 @@ NS_IMETHODIMP nsDocShell::Reload(PRInt32 aReloadType) else { //May be one of those charset reloads in a composer or Messenger return InternalLoad(mCurrentURI, mReferrerURI, nsnull, PR_TRUE, nsnull, - nsnull, type); + nsnull, nsnull, type); } #else @@ -1316,7 +1335,7 @@ NS_IMETHODIMP nsDocShell::Reload(PRInt32 aReloadType) // there is no major difference between this one and the one inside #if 0 return InternalLoad(mCurrentURI, mReferrerURI, nsnull, PR_TRUE, nsnull, - nsnull, type); + nsnull, nsnull, type); #endif /* 0 */ @@ -1335,8 +1354,9 @@ NS_IMETHODIMP nsDocShell::Reload(PRInt32 aReloadType) UpdateCurrentSessionHistory(); - NS_ENSURE_SUCCESS(InternalLoad(mCurrentURI, mReferrerURI, nsnull, PR_TRUE, nsnull, - nsnull, type), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(InternalLoad(mCurrentURI, mReferrerURI, nsnull, PR_TRUE, + nsnull, nsnull, nsnull, type), + NS_ERROR_FAILURE); return NS_OK; #endif /* SH_IN_FRAMES */ @@ -2677,13 +2697,13 @@ NS_IMETHODIMP nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) //***************************************************************************** #ifdef SH_IN_FRAMES NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer, - nsISupports* aOwner, PRBool aInheritOwner, - const char* aWindowTarget, nsIInputStream* aPostData, + nsISupports* aOwner, PRBool aInheritOwner, const char* aWindowTarget, + nsIInputStream* aPostData, nsIInputStream* aHeadersData, nsDocShellInfoLoadType aLoadType, nsISHEntry * aSHEntry) #else NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer, - nsISupports* aOwner, PRBool aInheritOwner, - const char* aWindowTarget, nsIInputStream* aPostData, + nsISupports* aOwner, PRBool aInheritOwner, const char* aWindowTarget, + nsIInputStream* aPostData, nsIInputStream* aHeadersData, nsDocShellInfoLoadType aLoadType) #endif { @@ -2745,7 +2765,8 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer, if(nsIDocShellLoadInfo::loadLink == aLoadType) loadCmd = nsIURILoader::viewUserClick; NS_ENSURE_SUCCESS(DoURILoad(aURI, aReferrer, aOwner, aInheritOwner, - loadCmd, aWindowTarget, aPostData), NS_ERROR_FAILURE); + loadCmd, aWindowTarget, + aPostData, aHeadersData), NS_ERROR_FAILURE); return NS_OK; } @@ -3008,8 +3029,9 @@ NS_IMETHODIMP nsDocShell::GetCurrentDocumentOwner(nsISupports** aOwner) } NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI, - nsISupports* aOwner, PRBool aInheritOwner, nsURILoadCommand aLoadCmd, - const char* aWindowTarget, nsIInputStream* aPostData) + nsISupports* aOwner, PRBool aInheritOwner, nsURILoadCommand aLoadCmd, + const char* aWindowTarget, nsIInputStream* aPostData, + nsIInputStream *aHeadersData) { static const char jsSchemeName[] = "javascript"; // if the load cmd is a user click....and we are supposed to try using @@ -3072,6 +3094,10 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI, httpChannel->SetRequestMethod(method); httpChannel->SetUploadStream(aPostData); } + if (aHeadersData) + { + rv = AddHeadersToChannel(aHeadersData, httpChannel); + } // Set the referrer explicitly if(aReferrerURI) // Referrer is currenly only set for link clicks here. httpChannel->SetReferrer(aReferrerURI, @@ -3109,6 +3135,164 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI, return NS_OK; } +static NS_METHOD AHTC_WriteFunc(nsIInputStream* in, + void* closure, + const char* fromRawSegment, + PRUint32 toOffset, + PRUint32 count, + PRUint32 *writeCount) +{ + if (nsnull == writeCount || nsnull == closure || + nsnull == fromRawSegment || nsCRT::strlen(fromRawSegment) < 1) { + return NS_BASE_STREAM_CLOSED; + } + + *writeCount = 0; + char *headersBuf = *((char **)closure); + // pointer to where we should start copying bytes from rawSegment + char *pHeadersBuf = nsnull; + PRUint32 headersBufLen; + PRUint32 rawSegmentLen = nsCRT::strlen(fromRawSegment); + + // if the buffer has no data yet + if (!headersBuf) { + headersBufLen = rawSegmentLen; + pHeadersBuf = headersBuf = (char *) nsMemory::Alloc(headersBufLen + 1); + if (!headersBuf) { + return NS_BASE_STREAM_WOULD_BLOCK; + } + nsCRT::memset(headersBuf, nsnull, headersBufLen + 1); + } + else { + // data has been read, reallocate + // store a pointer to the old full buffer + pHeadersBuf = headersBuf; + + // create a new buffer + headersBufLen = nsCRT::strlen(headersBuf); + headersBuf = (char *) nsMemory::Alloc(rawSegmentLen+headersBufLen + 1); + if (!headersBuf) { + headersBuf = pHeadersBuf; + pHeadersBuf = nsnull; + return NS_BASE_STREAM_WOULD_BLOCK; + } + memset(headersBuf, nsnull, rawSegmentLen + headersBufLen + 1); + // copy the old buffer to the beginning of the new buffer + nsCRT::memcpy(headersBuf, pHeadersBuf, headersBufLen); + // free the old buffer + nsCRT::free(pHeadersBuf); + // make the buffer pointer point to the writeable part + // of the new buffer + pHeadersBuf = headersBuf + headersBufLen; + // increment the length of the buffer + headersBufLen += rawSegmentLen; + } + + // at this point, pHeadersBuf points to where we should copy bits + // from fromRawSegment. + nsCRT::memcpy(pHeadersBuf, fromRawSegment, rawSegmentLen); + // null termination + headersBuf[headersBufLen] = nsnull; + *((char **)closure) = headersBuf; + *writeCount = rawSegmentLen; + + return NS_OK; +} + +NS_IMETHODIMP nsDocShell::AddHeadersToChannel(nsIInputStream *aHeadersData, + nsIChannel *aGenericChannel) +{ + if (nsnull == aHeadersData || nsnull == aGenericChannel) { + return NS_ERROR_NULL_POINTER; + } + nsCOMPtr aChannel = do_QueryInterface(aGenericChannel); + if (!aChannel) { + return NS_ERROR_NULL_POINTER; + } + + // used during the manipulation of the InputStream + nsresult rv = NS_ERROR_FAILURE; + PRUint32 available = 0; + PRUint32 bytesRead; + char *headersBuf = nsnull; + + // used during the manipulation of the String from the InputStream + nsCAutoString headersString; + nsCAutoString oneHeader; + nsCAutoString headerName; + nsCAutoString headerValue; + PRUint32 crlf = 0; + PRUint32 colon = 0; + nsIAtom *headerAtom; + + // + // Suck all the data out of the nsIInputStream into a char * buffer. + // + + rv = aHeadersData->Available(&available); + if (NS_FAILED(rv) || available < 1) { + goto AHTC_CLEANUP; + } + + do { + aHeadersData->ReadSegments(AHTC_WriteFunc, &headersBuf, available, + &bytesRead); + rv = aHeadersData->Available(&available); + if (NS_FAILED(rv)) { + goto AHTC_CLEANUP; + } + } while(0 < available); + + // + // Turn the char * buffer into an nsString. + // + headersString = (const char *) headersBuf; + + // + // Iterate over the nsString: for each "\r\n" delimeted chunk, + // add the value as a header to the nsIHTTPChannel + // + + while (true) { + crlf = headersString.Find("\r\n", PR_TRUE); + if (-1 == crlf) { + rv = NS_OK; + goto AHTC_CLEANUP; + } + headersString.Mid(oneHeader, 0, crlf); + headersString.Cut(0, crlf + 2); + oneHeader.StripWhitespace(); + colon = oneHeader.Find(":"); + if (-1 == colon) { + rv = NS_ERROR_NULL_POINTER; + goto AHTC_CLEANUP; + } + oneHeader.Left(headerName, colon); + colon++; + oneHeader.Mid(headerValue, colon, oneHeader.Length() - colon); + headerAtom = NS_NewAtom((const char *) headerName); + if (!headerAtom) { + rv = NS_ERROR_NULL_POINTER; + goto AHTC_CLEANUP; + } + + // + // FINALLY: we can set the header! + // + + rv =aChannel->SetRequestHeader(headerAtom, (const char *) headerValue); + if (NS_FAILED(rv)) { + rv = NS_ERROR_NULL_POINTER; + goto AHTC_CLEANUP; + } + } + + AHTC_CLEANUP: + nsMemory::Free((void *) headersBuf); + headersBuf = nsnull; + return rv; +} + NS_IMETHODIMP nsDocShell::DoChannelLoad(nsIChannel *aChannel, nsURILoadCommand aLoadCmd, const char* aWindowTarget, nsIURILoader *aURILoader) { @@ -3630,10 +3814,13 @@ NS_IMETHODIMP nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry) #ifdef SH_IN_FRAMES - NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, PR_TRUE, nsnull, postData, aLoadType, aEntry), + NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, PR_TRUE, nsnull, + postData, nsnull, aLoadType, aEntry), NS_ERROR_FAILURE); #else - NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, PR_TRUE, nsnull, postData, nsIDocShellLoadInfo::loadHistory), + NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, PR_TRUE, + postData, nsnull, + nsIDocShellLoadInfo::loadHistory), NS_ERROR_FAILURE); #endif diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index 412d8e6f000..ae66f881e8b 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -173,12 +173,14 @@ protected: #ifdef SH_IN_FRAMES NS_IMETHOD InternalLoad(nsIURI* aURI, nsIURI* aReferrerURI, - nsISupports* owner, PRBool inheritOwnerFromDocument, const char* aWindowTarget=nsnull, - nsIInputStream* aPostData=nsnull, nsDocShellInfoLoadType aLoadType=nsIDocShellLoadInfo::loadNormal, nsISHEntry * aSHEntry = nsnull); + nsISupports* owner, PRBool inheritOwnerFromDocument, + const char* aWindowTarget=nsnull, + nsIInputStream* aPostData=nsnull, nsIInputStream* aHeadersData=nsnull, nsDocShellInfoLoadType aLoadType=nsIDocShellLoadInfo::loadNormal, nsISHEntry * aSHEntry = nsnull); #else NS_IMETHOD InternalLoad(nsIURI* aURI, nsIURI* aReferrerURI, - nsISupports* owner, PRBool inheritOwnerFromDocument, const char* aWindowTarget=nsnull, - nsIInputStream* aPostData=nsnull, nsDocShellInfoLoadType aLoadType=nsIDocShellLoadInfo::loadNormal); + nsISupports* owner, PRBool inheritOwnerFromDocument, + const char* aWindowTarget=nsnull, + nsIInputStream* aPostData=nsnull, nsIInputStream* aHeadersData=nsnull, nsDocShellInfoLoadType aLoadType=nsIDocShellLoadInfo::loadNormal); #endif NS_IMETHOD CreateFixupURI(const PRUnichar* aStringURI, nsIURI** aURI); @@ -188,8 +190,11 @@ protected: NS_IMETHOD KeywordURIFixup(const PRUnichar* aStringURI, nsIURI** aURI); NS_IMETHOD GetCurrentDocumentOwner(nsISupports** aOwner); NS_IMETHOD DoURILoad(nsIURI* aURI, nsIURI* aReferrer, nsISupports *aOwner, - PRBool inheritOwnerFromDocument, nsURILoadCommand aLoadCmd, const char* aWindowTarget, - nsIInputStream* aPostData); + PRBool inheritOwnerFromDocument, nsURILoadCommand aLoadCmd, + const char* aWindowTarget, + nsIInputStream* aPostData, nsIInputStream* aHeadersData); + NS_IMETHOD AddHeadersToChannel(nsIInputStream *aHeadersData, + nsIChannel *aChannel); NS_IMETHOD DoChannelLoad(nsIChannel* aChannel, nsURILoadCommand aLoadCmd, const char* aWindowTarget, nsIURILoader *aURILoader); NS_IMETHOD ScrollIfAnchor(nsIURI* aURI, PRBool* aWasAnchor); @@ -291,6 +296,7 @@ protected: nsIDocShellTreeItem* mParent; // Weak Reference nsIDocShellTreeOwner* mTreeOwner; // Weak Reference nsIChromeEventHandler* mChromeEventHandler; //Weak Reference + }; #endif /* nsDocShell_h__ */ diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index a0dbdd6885a..6e4d5e50862 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -724,18 +724,21 @@ nsWebShell::SetRendering(PRBool aRender) struct OnLinkClickEvent : public PLEvent { OnLinkClickEvent(nsWebShell* aHandler, nsIContent* aContent, nsLinkVerb aVerb, const PRUnichar* aURLSpec, - const PRUnichar* aTargetSpec, nsIInputStream* aPostDataStream = 0); + const PRUnichar* aTargetSpec, nsIInputStream* aPostDataStream = 0, + nsIInputStream* aHeadersDataStream = 0); ~OnLinkClickEvent(); void HandleEvent() { mHandler->HandleLinkClickEvent(mContent, mVerb, mURLSpec->GetUnicode(), - mTargetSpec->GetUnicode(), mPostDataStream); + mTargetSpec->GetUnicode(), mPostDataStream, + mHeadersDataStream); } nsWebShell* mHandler; nsString* mURLSpec; nsString* mTargetSpec; nsIInputStream* mPostDataStream; + nsIInputStream* mHeadersDataStream; nsIContent* mContent; nsLinkVerb mVerb; }; @@ -755,7 +758,8 @@ OnLinkClickEvent::OnLinkClickEvent(nsWebShell* aHandler, nsLinkVerb aVerb, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec, - nsIInputStream* aPostDataStream) + nsIInputStream* aPostDataStream, + nsIInputStream* aHeadersDataStream) { nsIEventQueue* eventQueue; @@ -765,6 +769,8 @@ OnLinkClickEvent::OnLinkClickEvent(nsWebShell* aHandler, mTargetSpec = new nsString(aTargetSpec); mPostDataStream = aPostDataStream; NS_IF_ADDREF(mPostDataStream); + mHeadersDataStream = aHeadersDataStream; + NS_IF_ADDREF(mHeadersDataStream); mContent = aContent; NS_IF_ADDREF(mContent); mVerb = aVerb; @@ -783,6 +789,7 @@ OnLinkClickEvent::~OnLinkClickEvent() NS_IF_RELEASE(mContent); NS_IF_RELEASE(mHandler); NS_IF_RELEASE(mPostDataStream); + NS_IF_RELEASE(mHeadersDataStream); if (nsnull != mURLSpec) delete mURLSpec; if (nsnull != mTargetSpec) delete mTargetSpec; @@ -795,13 +802,14 @@ nsWebShell::OnLinkClick(nsIContent* aContent, nsLinkVerb aVerb, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec, - nsIInputStream* aPostDataStream) + nsIInputStream* aPostDataStream, + nsIInputStream* aHeadersDataStream) { OnLinkClickEvent* ev; nsresult rv = NS_OK; ev = new OnLinkClickEvent(this, aContent, aVerb, aURLSpec, - aTargetSpec, aPostDataStream); + aTargetSpec, aPostDataStream, aHeadersDataStream); if (nsnull == ev) { rv = NS_ERROR_OUT_OF_MEMORY; } @@ -820,7 +828,8 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, nsLinkVerb aVerb, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec, - nsIInputStream* aPostDataStream) + nsIInputStream* aPostDataStream, + nsIInputStream* aHeadersDataStream) { nsCAutoString target; target.AssignWithConversion(aTargetSpec); @@ -839,9 +848,12 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, NS_NewURI(getter_AddRefs(uri), nsLiteralString(aURLSpec), nsnull); #ifdef SH_IN_FRAMES - InternalLoad(uri, mCurrentURI, nsnull, PR_TRUE, target, aPostDataStream, nsIDocShellLoadInfo::loadLink, nsnull); + InternalLoad(uri, mCurrentURI, nsnull, PR_TRUE, target, aPostDataStream, + aHeadersDataStream, nsIDocShellLoadInfo::loadLink, nsnull); #else - InternalLoad(uri, mCurrentURI, nsnull, PR_TRUE, target, aPostDataStream, nsIDocShellLoadInfo::loadLink); + InternalLoad(uri, mCurrentURI, nsnull, PR_TRUE, target, + aPostDataStream, aHeadersDataStream, + nsIDocShellLoadInfo::loadLink); #endif /* SH_IN_FRAMES */ } break; diff --git a/mozilla/docshell/base/nsWebShell.h b/mozilla/docshell/base/nsWebShell.h index 94d184d42fe..961ec7fb83f 100644 --- a/mozilla/docshell/base/nsWebShell.h +++ b/mozilla/docshell/base/nsWebShell.h @@ -88,7 +88,8 @@ public: nsLinkVerb aVerb, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec, - nsIInputStream* aPostDataStream = 0); + nsIInputStream* aPostDataStream = 0, + nsIInputStream* aHeadersDataStream = 0); NS_IMETHOD OnOverLink(nsIContent* aContent, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec); @@ -111,7 +112,8 @@ public: nsLinkVerb aVerb, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec, - nsIInputStream* aPostDataStream = 0); + nsIInputStream* aPostDataStream = 0, + nsIInputStream* aHeadersDataStream = 0); static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 45002a6bf64..85047855b3e 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -89,7 +89,8 @@ public: NS_IMETHOD CreateWidget(void); NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData, - PRUint32 aPostDataLen); + PRUint32 aPostDataLen, void *aHeadersData, + PRUint32 aHeadersDataLen); NS_IMETHOD ShowStatus(const char *aStatusMsg); @@ -1671,7 +1672,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance) return NS_ERROR_FAILURE; } -NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen) +NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData, + PRUint32 aHeadersDataLen) { nsISupports *container; nsILinkHandler *lh; @@ -1710,6 +1712,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge mOwner->GetContent(&content); nsCOMPtr result = nsnull; nsCOMPtr postDataStream = nsnull; + nsCOMPtr headersDataStream = nsnull; if (aPostData) { NS_NewByteInputStream(getter_AddRefs(result), (const char *) aPostData, aPostDataLen); @@ -1717,18 +1720,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge postDataStream = do_QueryInterface(result, &rv); } } - if (postDataStream) { - rv = lh->OnLinkClick(content, eLinkVerb_Replace, - fullurl.GetUnicode(), - unitarget.GetUnicode(), - postDataStream); - } - else { - rv = lh->OnLinkClick(content, eLinkVerb_Replace, - fullurl.GetUnicode(), - unitarget.GetUnicode(), - nsnull); + if (aHeadersData) { + NS_NewByteInputStream(getter_AddRefs(result), + (const char *) aHeadersData, aHeadersDataLen); + if (result) { + headersDataStream = do_QueryInterface(result, &rv); + } } + rv = lh->OnLinkClick(content, eLinkVerb_Replace, + fullurl.GetUnicode(), + unitarget.GetUnicode(), + postDataStream, headersDataStream); NS_IF_RELEASE(content); } NS_RELEASE(lh); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 45002a6bf64..85047855b3e 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -89,7 +89,8 @@ public: NS_IMETHOD CreateWidget(void); NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData, - PRUint32 aPostDataLen); + PRUint32 aPostDataLen, void *aHeadersData, + PRUint32 aHeadersDataLen); NS_IMETHOD ShowStatus(const char *aStatusMsg); @@ -1671,7 +1672,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance) return NS_ERROR_FAILURE; } -NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen) +NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData, + PRUint32 aHeadersDataLen) { nsISupports *container; nsILinkHandler *lh; @@ -1710,6 +1712,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge mOwner->GetContent(&content); nsCOMPtr result = nsnull; nsCOMPtr postDataStream = nsnull; + nsCOMPtr headersDataStream = nsnull; if (aPostData) { NS_NewByteInputStream(getter_AddRefs(result), (const char *) aPostData, aPostDataLen); @@ -1717,18 +1720,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge postDataStream = do_QueryInterface(result, &rv); } } - if (postDataStream) { - rv = lh->OnLinkClick(content, eLinkVerb_Replace, - fullurl.GetUnicode(), - unitarget.GetUnicode(), - postDataStream); - } - else { - rv = lh->OnLinkClick(content, eLinkVerb_Replace, - fullurl.GetUnicode(), - unitarget.GetUnicode(), - nsnull); + if (aHeadersData) { + NS_NewByteInputStream(getter_AddRefs(result), + (const char *) aHeadersData, aHeadersDataLen); + if (result) { + headersDataStream = do_QueryInterface(result, &rv); + } } + rv = lh->OnLinkClick(content, eLinkVerb_Replace, + fullurl.GetUnicode(), + unitarget.GetUnicode(), + postDataStream, headersDataStream); NS_IF_RELEASE(content); } NS_RELEASE(lh); diff --git a/mozilla/modules/plugin/base/src/nsIPluginInstanceOwner.h b/mozilla/modules/plugin/base/src/nsIPluginInstanceOwner.h index eee5a6f5dff..f5b79d53daa 100644 --- a/mozilla/modules/plugin/base/src/nsIPluginInstanceOwner.h +++ b/mozilla/modules/plugin/base/src/nsIPluginInstanceOwner.h @@ -81,8 +81,9 @@ public: * */ NS_IMETHOD - GetURL(const char *aURL, const char *aTarget, void *aPostData, - PRUint32 aPostDataLen) = 0; + GetURL(const char *aURL, const char *aTarget, + void *aPostData, PRUint32 aPostDataLen, + void *aHeadersData, PRUint32 aHeadersDataLen) = 0; /** * Show a status message in the host environment. diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index b725e472902..d62f8c95cf7 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -1484,7 +1484,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, else if (0 == PL_strcmp(target, "_current")) target = "_self"; - rv = owner->GetURL(url, target, nsnull, 0); + rv = owner->GetURL(url, target, nsnull, 0, nsnull, nsnull); } NS_RELEASE(peer); @@ -1549,7 +1549,8 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst, else if (0 == PL_strcmp(target, "_current")) target = "_self"; } - rv = owner->GetURL(url, target, (void*)postData, postDataLen); + rv = owner->GetURL(url, target, (void*)postData, postDataLen, + (void*) postHeaders, postHeadersLength); } NS_RELEASE(peer); diff --git a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp index 72f95de753a..768a0fb2648 100644 --- a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp @@ -270,7 +270,7 @@ nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteC PRUint32 actualCount; mFileThing->Write(aBuf, aCount, &actualCount); mFileThing->Close(); - mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0); + mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); return NS_OK; } @@ -320,7 +320,7 @@ nsPluginStreamToFile::SetObserver(nsIOutputStreamObserver * aObserver) NS_IMETHODIMP nsPluginStreamToFile::Close(void) { - mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0); + mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); return NS_OK; } diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index 5f27d9fbc85..431dde1f89b 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -100,8 +100,9 @@ public: NS_IMETHOD CreateWidget(void); - NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData, - PRUint32 aPostDataLen); + NS_IMETHOD GetURL(const char *aURL, const char *aTarget, + void *aPostData, PRUint32 aPostDataLen, + void *aHeadersData, PRUint32 aHeadersDataLen); NS_IMETHOD ShowStatus(const char *aStatusMsg); @@ -816,7 +817,8 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void) return NS_OK; } -NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen) +NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData, + PRUint32 aHeadersDataLen) { nsresult rv; diff --git a/mozilla/modules/plugin/nglsrc/nsIPluginInstanceOwner.h b/mozilla/modules/plugin/nglsrc/nsIPluginInstanceOwner.h index eee5a6f5dff..f5b79d53daa 100644 --- a/mozilla/modules/plugin/nglsrc/nsIPluginInstanceOwner.h +++ b/mozilla/modules/plugin/nglsrc/nsIPluginInstanceOwner.h @@ -81,8 +81,9 @@ public: * */ NS_IMETHOD - GetURL(const char *aURL, const char *aTarget, void *aPostData, - PRUint32 aPostDataLen) = 0; + GetURL(const char *aURL, const char *aTarget, + void *aPostData, PRUint32 aPostDataLen, + void *aHeadersData, PRUint32 aHeadersDataLen) = 0; /** * Show a status message in the host environment. diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index b725e472902..d62f8c95cf7 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -1484,7 +1484,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, else if (0 == PL_strcmp(target, "_current")) target = "_self"; - rv = owner->GetURL(url, target, nsnull, 0); + rv = owner->GetURL(url, target, nsnull, 0, nsnull, nsnull); } NS_RELEASE(peer); @@ -1549,7 +1549,8 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst, else if (0 == PL_strcmp(target, "_current")) target = "_self"; } - rv = owner->GetURL(url, target, (void*)postData, postDataLen); + rv = owner->GetURL(url, target, (void*)postData, postDataLen, + (void*) postHeaders, postHeadersLength); } NS_RELEASE(peer); diff --git a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp index 72f95de753a..768a0fb2648 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp @@ -270,7 +270,7 @@ nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteC PRUint32 actualCount; mFileThing->Write(aBuf, aCount, &actualCount); mFileThing->Close(); - mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0); + mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); return NS_OK; } @@ -320,7 +320,7 @@ nsPluginStreamToFile::SetObserver(nsIOutputStreamObserver * aObserver) NS_IMETHODIMP nsPluginStreamToFile::Close(void) { - mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0); + mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); return NS_OK; } diff --git a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp index 5f27d9fbc85..431dde1f89b 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp @@ -100,8 +100,9 @@ public: NS_IMETHOD CreateWidget(void); - NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData, - PRUint32 aPostDataLen); + NS_IMETHOD GetURL(const char *aURL, const char *aTarget, + void *aPostData, PRUint32 aPostDataLen, + void *aHeadersData, PRUint32 aHeadersDataLen); NS_IMETHOD ShowStatus(const char *aStatusMsg); @@ -816,7 +817,8 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void) return NS_OK; } -NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen) +NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData, + PRUint32 aHeadersDataLen) { nsresult rv; diff --git a/mozilla/webshell/public/nsILinkHandler.h b/mozilla/webshell/public/nsILinkHandler.h index 9135ba03b12..4a00526eaae 100644 --- a/mozilla/webshell/public/nsILinkHandler.h +++ b/mozilla/webshell/public/nsILinkHandler.h @@ -69,7 +69,8 @@ public: nsLinkVerb aVerb, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec, - nsIInputStream* aPostDataStream = 0) = 0; + nsIInputStream* aPostDataStream = 0, + nsIInputStream* aHeadersDataStream = 0) = 0; /** * Process a mouse-over a link. aContent is the