Hello sir,
Well i tried to find the creation of HTTPServerListener Object but i could
find it only in the following function.
Is there any other place where an object of that type is getting created.
Becoz i feel that thiis function does not get executed.
(well yes i am rferring to the 0.9 version of source code. Also note that i
have just shown below the functions which i was looking at.)
nsHTTPPipelinedRequest::OnStopRequest(nsIRequest *request, nsISupports*
aContext,
nsresult aStatus)
{
nsresult rv;
nsCOMPtr<nsISocketTransport> trans = do_QueryInterface(mTransport, &rv);
nsHTTPRequest * req =(nsHTTPRequest *) mRequests->ElementAt(0);
rv = aStatus;
LOG(("\nnsHTTPRequest::OnStopRequest() [this=%x], aStatus=%u\n",
this, aStatus));
if (NS_SUCCEEDED(rv)) {
PRBool isAlive = PR_TRUE;
if (!mListener && trans)
trans->IsAlive(0, &isAlive);
if (isAlive) {
//
// Write the input stream data to the server...
//
if (mInputStream) {
LOG(("nsHTTPRequest [this=%x]. "
"Writing PUT/POST data to the server.\n", this));
rv = NS_AsyncWriteFromStream(
getter_AddRefs(mCurrentWriteRequest),
mTransport, mInputStream, 0, 0, 0,
this, NS_STATIC_CAST(nsIRequest*,
req->mConnection));
/* the mInputStream is released below... */
}
//
// Prepare to receive the response...
//
else {
LOG(("nsHTTPRequest [this=%p]. "
"Finished writing request to server."
"\tStatus: %x\n", this, aStatus));
if (mListener == nsnull) {
////////////////////////////////////////////////////////////////////////////
///////////
nsHTTPResponseListener* pListener = new
nsHTTPServerListener(
req->mConnection,
mHandler,
this,
req->mDoingProxySSLConnect);
////////////////////////////////////////////////////////////////////////////
///////////
if (pListener) {
NS_ADDREF(pListener);
rv = mTransport->AsyncRead(pListener, aContext, 0,
(PRUint32) -1, 0,
getter_AddRefs(mCurrentReadRequest));
mListener = pListener;
NS_RELEASE(pListener);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
mOnStopDone = PR_TRUE;
// write again to see if anything else is queued up
WriteRequest(mInputStream);
}
}
else
rv = NS_ERROR_FAILURE;
}
//
// An error occurred when trying to write the request to the server!
//
else {
LOG(("nsHTTPRequest [this=%p]. Error writing request to server."
"\tStatus: %x\n", this, aStatus));
rv = aStatus;
}
//
// An error occurred... Finish the transaction and notify the consumer
// of the failure...
//
if (NS_FAILED(rv)) {
if (mTotalProcessed == 0 && mAttempts == 0 && mTotalWritten) {
// the pipeline just started - we still can attempt to recover
PRUint32 wasKeptAlive = 0;
nsresult channelStatus = NS_OK;
if (trans)
trans->GetReuseCount(&wasKeptAlive);
req->mConnection->GetStatus(&channelStatus);
LOG(("nsHTTPRequest::OnStopRequest() [this=%p]. wasKeptAlive=%d,
channelStatus=%x\n",
this, wasKeptAlive, channelStatus));
if (wasKeptAlive && NS_SUCCEEDED(channelStatus)) {
mMustCommit = PR_TRUE;
mAttempts++;
mTotalWritten = 0;
mHandler->ReleaseTransport(mTransport,
nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES,
PR_TRUE);
mTransport = null_nsCOMPtr();
mCurrentWriteRequest = 0;
mCurrentReadRequest = 0;
mOnStopDone = PR_TRUE;
rv = WriteRequest(mInputStream);
if (NS_SUCCEEDED(rv)) {
NS_IF_RELEASE(req);
return rv;
}
}
}
while (req) {
nsCOMPtr<nsIStreamListener> consumer;
req->mConnection->GetResponseDataListener(getter_AddRefs(consumer));
req->mConnection->ResponseCompleted(consumer, rv);
// Notify the HTTPChannel that the request has finished
if (mTransport) {
nsITransport *p = mTransport;
mTransport = 0;
mCurrentWriteRequest = 0;
mCurrentReadRequest = 0;
mHandler->ReleaseTransport(p,
nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES);
}
NS_IF_RELEASE(req);
req = nsnull;
if (NS_SUCCEEDED(AdvanceToNextRequest()))
GetCurrentRequest(&req);
}
}
NS_IF_RELEASE(req);
//
// These resouces are no longer needed...
//
// mRequestBuffer.Truncate();
mInputStream = null_nsCOMPtr();
mOnStopDone = PR_TRUE;
if (NS_FAILED(rv) && !mListener)
mHandler->ReleasePipelinedRequest(this);
return rv;
}
The place where the object nsDocumentopenInfo is getting created is :
NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsISupports * aOriginalWindowContext,
PRUint32 aLocalIP)
{
// we need to create a DocumentOpenInfo object which will go ahead and
open the url
// and discover the content type....
nsresult rv = NS_OK;
nsDocumentOpenInfo* loader = nsnull;
if (!channel) return NS_ERROR_NULL_POINTER;
// Let the window context's uriListener know that the open is starting.
This
// gives that window a chance to abort the load process.
nsCOMPtr<nsIURIContentListener>
winContextListener(do_GetInterface(aOriginalWindowContext));
if(winContextListener)
{
// get channel from request
nsCOMPtr<nsIURI> uri;
channel->GetURI(getter_AddRefs(uri));
if(uri)
{
PRBool doAbort = PR_FALSE;
winContextListener->OnStartURIOpen(uri, aWindowTarget, &doAbort);
if(doAbort)
return NS_OK;
}
}
nsCAutoString windowTarget(aWindowTarget);
nsCOMPtr<nsISupports> retargetedWindowContext;
NS_ENSURE_SUCCESS(GetTarget(channel, windowTarget, aOriginalWindowContext,
getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE);
/.//////////////////////////////////////////////////////////////////////////
////////
NS_NEWXPCOM(loader, nsDocumentOpenInfo);
////////////////////////////////////////////////////////////////////////////
//////
if (!loader) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(loader);
nsCOMPtr<nsIInterfaceRequestor> loadCookie;
SetupLoadCookie(retargetedWindowContext, getter_AddRefs(loadCookie));
loader->Init(retargetedWindowContext, aOriginalWindowContext); // Extra
Info
// now instruct the loader to go ahead and open the url
rv = loader->Open(channel, aCommand, windowTarget,
retargetedWindowContext); (This function call finally goes to asyncopen
of HTTPChannel given
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////
below)
NS_RELEASE(loader);
return rv;
}
Also i could find the place where the object of type nsHTTPFinalListener is
created. and that is
nsHTTPChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
*aContext)
{
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(aListener);
if (mResponseDataListener)
return NS_ERROR_IN_PROGRESS;
////////////////////////////////////////////////////////////////////////////
////////
mResponseDataListener = new nsHTTPFinalListener(this, //////////
Is this the object on which the OnStartRequest Method is being called
???????
aListener,
aContext);
///////////////////////////////////////////////////////////////////////
if (!mResponseDataListener)
return NS_ERROR_OUT_OF_MEMORY;
mResponseContext = aContext;
// start loading the requested document
Connect();
#ifndef MOZ_NEW_CACHE
// If the data in the cache hasn't expired, then there's no need to talk
// with the server. Create a stream from the cache, synthesizing all
the
// various channel-related events.
if (mCachedContentIsValid)
ReadFromCache();
#endif
return rv;
}
So please tell me where the nsHTTPServerListener Object is getting created.
It would be very helpful if u could point to the source code.
Thanking You
Yours sincerely
Pras