Exemplo n.º 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");
            }
        }
Exemplo n.º 2
0
        public void Start(string szURL, IInternetProtocolSink Sink, IInternetBindInfo pOIBindInfo, uint grfPI, uint dwReserved)
        {
            Debug.WriteLine("Start:" + szURL, "Info");
            try
            {
                if (Sink is IServiceProvider)
                {
                    Debug.WriteLine("ServiceProvider");
                    IServiceProvider Provider      = (IServiceProvider)Sink;
                    object           obj_Negotiate = new object();
                    Provider.QueryService(ref Guids.IID_IHttpNegotiate, ref Guids.IID_IHttpNegotiate, out obj_Negotiate);
                    IHttpNegotiate Negotiate = (IHttpNegotiate)obj_Negotiate;

                    string strNewHeaders;
                    Negotiate.BeginningTransaction(szURL, string.Empty, 0, out strNewHeaders);
                    Debug.WriteLine(strNewHeaders);

                    using (var resourceStream = _embeddedResourceMap.GetStream(szURL))
                    {
                        if (resourceStream == null)
                        {
                            StreamWriter Writer = new StreamWriter(Stream);
                            Writer.Write("<html><body><p>Cannot find resource: {0}</p></body></html>", szURL);
                            Writer.Flush();
                            Stream.Position = 0;
                        }
                        else
                        {
                            resourceStream.CopyTo(Stream);
                            Stream.Position = 0;
                        }
                    }

                    string StrResponseHeaders = string.Format("HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length:{0}\r\n\r\n", Stream.Length);
                    string strNewResponseHeaders;
                    Negotiate.OnResponse(200, StrResponseHeaders, strNewHeaders, out strNewResponseHeaders);
                    Debug.WriteLine(strNewResponseHeaders);
                }

                Sink.ReportData(BSCF.BSCF_LASTDATANOTIFICATION, (uint)Stream.Length, (uint)Stream.Length);
                Sink.ReportResult(0, 200, null);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
Exemplo n.º 3
0
        public void Start(string szURL, IInternetProtocolSink Sink, IInternetBindInfo pOIBindInfo, uint grfPI, uint dwReserved)
        {
            Debug.WriteLine("Start:" + szURL, "Info");
            try
            {
                if (Sink is IServiceProvider)
                {
                    Debug.WriteLine("ServiceProvider");
                    IServiceProvider Provider      = (IServiceProvider)Sink;
                    object           obj_Negotiate = new object();
                    Provider.QueryService(ref Guids.IID_IHttpNegotiate, ref Guids.IID_IHttpNegotiate, out obj_Negotiate);
                    IHttpNegotiate Negotiate = (IHttpNegotiate)obj_Negotiate;

                    string strNewHeaders;
                    Negotiate.BeginningTransaction(szURL, string.Empty, 0, out strNewHeaders);
                    Debug.WriteLine(strNewHeaders);

                    StreamWriter Writer = new StreamWriter(Stream);
                    int          loc    = szURL.IndexOf(':');
                    if (loc >= 0)
                    {
                        Writer.Write(string.Format("<HTML><BODY>{0}</BODY></HTML>", System.Web.HttpUtility.UrlDecode(szURL.Remove(0, loc + 1))));
                    }
                    else
                    {
                        Writer.Write(string.Format("<HTML><BODY>{0}</BODY></HTML>", System.Web.HttpUtility.UrlDecode(szURL)));
                    }
                    Writer.Flush();
                    Stream.Position = 0;

                    string StrResponseHeaders = string.Format("HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length:{0}\r\n\r\n", Stream.Length);
                    string strNewResponseHeaders;
                    Negotiate.OnResponse(200, StrResponseHeaders, strNewHeaders, out strNewResponseHeaders);
                    Debug.WriteLine(strNewResponseHeaders);
                }

                Sink.ReportData(BSCF.BSCF_LASTDATANOTIFICATION, (uint)Stream.Length, (uint)Stream.Length);
                Sink.ReportResult(0, 200, null);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }