Dear All,

I need to get the HTTP Header details and post parameters for all the request sent from the browser.

By implementing nsIWebProgressListener i am able to get nsIHTTPChannel and the header details.

To get postdata informations i am reading the data from nsIUploadChannel->uploadStream. After reading there is no more data available to send to the server.

My code to get the post data parameter is as below

nsCOMPtr<nsIUploadChannel> uploadChannel (do_QueryInterface(channel));
       if(uploadChannel)
       {
           nsCOMPtr<nsIInputStream> is;
           uploadChannel->GetUploadStream(getter_AddRefs(is));
           if(is)
           {
               PRUint32 available;
               is->Available(&available);

               if(available>0)
               {
                   PRBool aResult;
                   nsString postdata;
                   nsLineBuffer* mLineBuffer;
                   NS_InitLineBuffer(&mLineBuffer);
                   PRUint32 readBytes = 0;
                   nsString postParams;
                   postParams.AssignWithConversion("");

                   while(readBytes<available)
                   {
                       NS_ReadLine(is,mLineBuffer,postdata,&aResult);
                       readBytes=readBytes+postdata.Length()+2;
                       postParams.Append(postdata);
                       postParams.AppendWithConversion("\r\n");
                   }

                   PR_FREEIF(mLineBuffer);
                   mLineBuffer = nsnull;
               }

           }
       }
Please advice me how i should read the stream to get the post parameters.

Thanks & Regards,
Raghavan
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to