当前位置: 首页>>代码示例>>C#>>正文


C# HTTPMessage.Clone方法代码示例

本文整理汇总了C#中OpenSource.UPnP.HTTPMessage.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# HTTPMessage.Clone方法的具体用法?C# HTTPMessage.Clone怎么用?C# HTTPMessage.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSource.UPnP.HTTPMessage的用法示例。


在下文中一共展示了HTTPMessage.Clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SniffSessionSink3

 private void SniffSessionSink3(HTTPSession sender, HTTPMessage msg)
 {
     if (OnSniffPacket != null)
         OnSniffPacket((HTTPMessage)msg.Clone());
 }
开发者ID:genielabs,项目名称:intel-upnp-dlna,代码行数:5,代码来源:UPnPDevice.cs

示例2: HandleHeaderRequest

        private void HandleHeaderRequest(HTTPMessage msg, HTTPSession WebSession)
        {
            DText parser = new DText();
            HTTPMessage Response = new HTTPMessage();
            String Method = msg.Directive;
            String MethodData = msg.DirectiveObj;

            VirtualDirectoryHandler H_cb = null;
            VirtualDirectoryHandler P_cb = null;

            String vd = "";
            String vdobj = "";

            // Check VirtualDirTable
            int vdi;
            try
            {
                vdi = MethodData.IndexOf("/", 1);
                if (vdi != -1)
                {
                    vdobj = MethodData.Substring(vdi);
                    vd = MethodData.Substring(0, vdi);
                    if (VirtualDir_Header_Table.ContainsKey(vd))
                    {
                        if (VirtualDir_Header_Table[vd] != null)
                            H_cb = (VirtualDirectoryHandler)VirtualDir_Header_Table[vd];
                    }
                    if (VirtualDir_Table.ContainsKey(vd))
                    {
                        if (VirtualDir_Table[vd] != null)
                            P_cb = (VirtualDirectoryHandler)VirtualDir_Table[vd];
                    }
                }
            }
            catch (Exception ex)
            {
                OpenSource.Utilities.EventLogger.Log(ex);
            }

            if ((H_cb != null) || (P_cb != null))
            {
                HTTPMessage _msg = (HTTPMessage)msg.Clone();
                _msg.DirectiveObj = vdobj;
                WebSession.InternalStateObject = new Object[3] { vd, vdobj, P_cb };
                if (H_cb != null)
                    H_cb(this, _msg, WebSession, vd);
                return;
            }
        }
开发者ID:genielabs,项目名称:intel-upnp-dlna,代码行数:49,代码来源:UPnPDevice.cs

示例3: HandleWebRequest

        private void HandleWebRequest(HTTPMessage msg, HTTPSession WebSession)
        {
            DText parser = new DText();
            HTTPMessage Response = new HTTPMessage();
            HTTPMessage Response2 = null;
            String Method = msg.Directive;
            String MethodData = msg.DirectiveObj;

            if (WebSession.InternalStateObject != null)
            {
                HTTPMessage _msg = (HTTPMessage)msg.Clone();
                object[] state = (object[])WebSession.InternalStateObject;
                _msg.DirectiveObj = (string)state[1];
                VirtualDirectoryHandler t = (VirtualDirectoryHandler)state[2];
                WebSession.InternalStateObject = null;
                t(this, _msg, WebSession, (string)state[0]);
                return;

            }

            if ((Method != "GET") && (Method != "HEAD") && (Method != "POST") &&
                (Method != "SUBSCRIBE") && (Method != "UNSUBSCRIBE") &&
                (Method != "NOTIFY"))
            {
                Response.StatusCode = 405;
                Response.StatusData = Method + " not supported";
                WebSession.Send(Response);
                return; // Other methods are unknown to us
            }

            // Process Headers
            if (Method == "GET" || Method == "HEAD")
            {
                try
                {
                    Response = Get(MethodData, WebSession.Source);
                }
                catch (UPnPCustomException ce)
                {
                    OpenSource.Utilities.EventLogger.Log(ce);
                    Response.StatusCode = ce.ErrorCode;
                    Response.StatusData = ce.ErrorDescription;
                    WebSession.Send(Response);
                    return;
                }
                catch (Exception e)
                {
                    OpenSource.Utilities.EventLogger.Log(e);
                    Response.StatusCode = 500;
                    Response.StatusData = "Internal";
                    Response.StringBuffer = e.ToString();
                }
                if (Method == "HEAD")
                {
                    Response.BodyBuffer = null;
                }
                WebSession.Send(Response);
            }

            if (Method == "POST")
            {
                //InvokerInfo[Thread.CurrentThread.GetHashCode()] = WebSession;
                try
                {
                    Response = Post(MethodData, msg.StringBuffer, msg.GetTag("SOAPACTION"), WebSession);
                }
                catch (DelayedResponseException ex)
                {
                    OpenSource.Utilities.EventLogger.Log(ex);
                    InvokerInfo.Remove(Thread.CurrentThread.GetHashCode());
                    WebSession.StopReading();
                    return;
                }
                catch (UPnPCustomException ce)
                {
                    OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "UPnP Error [" + ce.ErrorCode.ToString() + "] " + ce.ErrorDescription);
                    Response.StatusCode = 500;
                    Response.StatusData = "Internal";
                    Response.StringBuffer = BuildErrorBody(ce);
                    WebSession.Send(Response);
                    InvokerInfo.Remove(Thread.CurrentThread.GetHashCode());
                    return;
                }
                catch (UPnPInvokeException ie)
                {
                    Response.StatusCode = 500;
                    Response.StatusData = "Internal";
                    if (ie.UPNP != null)
                    {
                        OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "UPnP Error [" + ie.UPNP.ErrorCode.ToString() + "] " + ie.UPNP.ErrorDescription);
                        Response.StringBuffer = BuildErrorBody(ie.UPNP);
                    }
                    else
                    {
                        OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "UPnP Invocation Error [" + ie.MethodName + "] " + ie.Message);
                        Response.StringBuffer = BuildErrorBody(new UPnPCustomException(500, ie.Message));
                    }
                    WebSession.Send(Response);
                    InvokerInfo.Remove(Thread.CurrentThread.GetHashCode());
                    return;
//.........这里部分代码省略.........
开发者ID:genielabs,项目名称:intel-upnp-dlna,代码行数:101,代码来源:UPnPDevice.cs

示例4: Send

		/// <summary>
		/// Sends a Packet to the computer connected to this session
		/// </summary>
		/// <param name="Packet">The Packet to Send</param>
		public void Send(HTTPMessage Packet)
		{
			OnSniffEvent.Fire(Packet.RawPacket, 0, Packet.RawPacket.Length);
			OnSniffPacketEvent.Fire(this,(HTTPMessage)Packet.Clone());
			if (OpenSource.Utilities.EventLogger.Enabled)
			{
				OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,Packet.StringPacket);
			}

			if (Packet.Version=="1.0")
			{
				this.IsLegacy=true;
			}
			else
			{
				this.IsLegacy=false;
			}

			lock(SendQueue)
			{
				if (SendQueue.Count==0)
				{
					if (MainSocket!=null)
					{
						MainSocket.Send(Packet.RawPacket);
						if (Packet.StatusCode>=200) this.SET_REQUEST_ANSWERED();
					}
				}
				else
				{
					SendQueue.Enqueue(Packet);
				}
			}

			/*
			if (Packet.StatusCode>=200)
			{
				// Send Complete Event
				this.SET_REQUEST_ANSWERED();
			}
			*/
		}
开发者ID:Scannow,项目名称:SWYH,代码行数:46,代码来源:HTTPSession.cs


注:本文中的OpenSource.UPnP.HTTPMessage.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。