Hi, I am trying to write an extension in c++ which captures and dumps all the outgoing data, which includes headers and body.
Till now, I have implemented a http handler which replaces the original handler, so that I can create my own channel, in my channel I have implemented the nsIUploadChannel interface which gathers the POST data, the headers are available in the ASyncOpen method. But the problem I am facing is that the SetUploadStream method is called only for the first chunk of data, I was under the assumption that it would either give me all the data in one go, or it would be called multiple times, but none of the above happens. Any help is appreciated. This is how my code looks like NS_IMETHODIMP DLPHTTPChannel::SetUploadStream(nsIInputStream *aInputStream, const nsACString & aContentType, PRInt32 aContentLength) { if (NULL != aInputStream) { PRUint32 uiContentLength = 0; aInputStream->Available(&uiContentLength); if (uiContentLength > 0) { //According to the doc. both the interfaces should be implemented. nsCOMPtr<nsISeekableStream> spSeekableInputStream = do_QueryInterface (aInputStream); spSeekableInputStream->Seek (nsISeekableStream::NS_SEEK_SET, 0); PRUint32 uiTotalDateRead = 0; while (uiTotalDateRead != uiContentLength) { PRUint32 uiDataRead = 0; PRUint32 uiDataToBeRead = uiContentLength - uiTotalDateRead; AutoPtr<char> spData = AutoPtr<char> (new char [uiDataToBeRead]); aInputStream->Read (spData.get(),uiDataToBeRead, &uiDataRead); C_LOG_DEBUG_MSG_1 (_T("Post Data : \n%s"), String (uiDataRead, spData.get()).c_str()); //Rewinding the stream spSeekableInputStream->Seek (nsISeekableStream::NS_SEEK_SET, uiDataRead); uiTotalDateRead += uiDataRead; } //Rewinding the stream spSeekableInputStream->Seek (nsISeekableStream::NS_SEEK_SET, 0); } } //return m_spMozillaHTTPChannel->Cancel (NS_ERROR_ABORT); return m_spUploadChannel->SetUploadStream (aInputStream, aContentType, aContentLength); } Plz help. Thanks Prasad _______________________________________________ dev-tech-network mailing list dev-tech-network@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-network