Example #1
0
        public void Start(string szURL, IInternetProtocolSink Sink, IInternetBindInfo pOIBindInfo, uint grfPI, uint dwReserved)
        {
            //System.Diagnostics.Debugger.Launch();
            AspNetRequestData RequestData = new AspNetRequestData(Stream);

            try
            {
                BINDINFO BindInfo = GetBindInfo(pOIBindInfo);
                RequestData.Verb     = GetVerb(BindInfo);
                RequestData.PostData = GetPostData(BindInfo);

                IHttpNegotiate Negotiate = GetHttpNegotiate(Sink);
                string         strRequestHeaders;
                Negotiate.BeginningTransaction(szURL, string.Empty, 0, out strRequestHeaders);
                RequestData.SetRequestHeaders(strRequestHeaders);

                ProcessRequest(RequestData, szURL);

                string strNewResponseHeaders;
                Negotiate.OnResponse(200, RequestData.GetResponseHeaders(), strRequestHeaders, out strNewResponseHeaders);

                //This must be the size of the buffer.
                Sink.ReportData(BSCF.BSCF_LASTDATANOTIFICATION, (uint)Stream.Length, (uint)Stream.Length);

                Sink.ReportResult(0, RequestData.Status, RequestData.StatusDescription);
            }
            catch (Exception e)
            {
                WriteBasicMessage(e.Message + "<hr>" + e.StackTrace, "Error");
            }
        }
        public static BINDINFO GetBindInfo(IInternetBindInfo pOIBindInfo)
        {
            BINDINFO BindInfo = new BINDINFO();

            BindInfo.cbSize = (UInt32)Marshal.SizeOf(typeof(BINDINFO));
            UInt32 AsyncFlag;

            pOIBindInfo.GetBindInfo(out AsyncFlag, ref BindInfo);
            return(BindInfo);
        }
Example #3
0
 public string GetVerb(BINDINFO BindInfo)
 {
     if (BindInfo.dwBindVerb == BINDVERB.BINDVERB_GET)
     {
         return("GET");
     }
     if (BindInfo.dwBindVerb == BINDVERB.BINDVERB_POST)
     {
         return("POST");
     }
     throw new Exception("the Aspx protocol currently only accepts get and post verbs.");
 }
Example #4
0
        public byte[] GetPostData(BINDINFO BindInfo)
        {
            if (BindInfo.dwBindVerb != BINDVERB.BINDVERB_POST)
            {
                return(new byte[0]);
            }
            byte[] result = new byte[0];
            if (BindInfo.stgmedData.enumType == TYMED.TYMED_HGLOBAL)
            {
                UInt32 length = BindInfo.cbStgmedData;
                result = new byte[length];

                Marshal.Copy(BindInfo.stgmedData.u, result, 0, (int)length);
                if (BindInfo.stgmedData.pUnkForRelease == null)
                {
                    Marshal.FreeHGlobal(BindInfo.stgmedData.u);
                }
            }
            return(result);
        }