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


C# HttpConnection类代码示例

本文整理汇总了C#中HttpConnection的典型用法代码示例。如果您正苦于以下问题:C# HttpConnection类的具体用法?C# HttpConnection怎么用?C# HttpConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ApiClient

        protected ApiClient(ApiKeyConnection connection)
        {
            Ensure.ArgumentNotNull(connection, nameof(connection));

            ApiKeyConnection = connection;
            HttpConnection = new HttpConnection(ApiKeyConnection);
        }
开发者ID:0xdeafcafe,项目名称:luno-dotnet,代码行数:7,代码来源:ApiClient.cs

示例2: GetConnection

 IObservable<HttpConnection> GetConnection(Uri uri)
 {
     if(m_connection!= null 
         && m_connection.Uri.Host==uri.Host 
         && m_connection.Uri.Port==uri.Port
         && m_connection.IsConnected
         )
     {
         return Observable.Return(m_connection)
             .Do(x =>
             {
                 Console.WriteLine("<KeepAlive>");
             })
             ;
     }
     else
     {
         return HttpConnection.Create(uri).Connect()
             .Do(x => {
                 m_connection = x;
                 Console.WriteLine(x);
             })
             ;
     }
 }
开发者ID:ousttrue,项目名称:ReactiveWeb,代码行数:25,代码来源:Program.cs

示例3: SendMessageSendsAndReceivesAMessage

 public void SendMessageSendsAndReceivesAMessage()
 {
     var action = "DoSomething";
     var request = new ServerRequest
     {
         ServerName = "TestServer"
     };
     var url = "http://somewhere/";
     var factory = new TestClientFactory((u, a, d) =>
     {
         Assert.AreEqual(url + "server/TestServer/RawXmlMessage.aspx", u.AbsoluteUri);
         Assert.AreEqual("POST", a);
         Assert.AreEqual(action, d["action"]);
         Assert.AreEqual(request.ToString(), d["message"]);
         var theResponse = new Response
         {
             RequestIdentifier = request.Identifier
         };
         return Encoding.UTF8.GetBytes(theResponse.ToString());
     });
     var connection = new HttpConnection(new Uri(url), factory);
     var response = connection.SendMessage(action, request);
     Assert.IsInstanceOf<Response>(response);
     Assert.AreEqual(request.Identifier, response.RequestIdentifier);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:25,代码来源:HttpConnectionTests.cs

示例4: HttpListenerContext

 internal HttpListenerContext(HttpConnection cnc, ILogger logger)
 {
     this.cnc = cnc;
     _logger = logger;
     request = new HttpListenerRequest(this);
     response = new HttpListenerResponse(this, _logger);
 }
开发者ID:tekhedd,项目名称:SocketHttpListener,代码行数:7,代码来源:HttpListenerContext.cs

示例5: Setup

        public void Setup()
        {
            requestedUrl.Clear();
            partialData = false;
            int i;
            for (i = 0; i < 1000; i++)
            {
                try
                {
                    listener = new HttpListener();
                    listener.Prefixes.Add(string.Format(listenerURL, i));
                    listener.Start();
                    break;
                }
                catch
                {

                }
            }
            listener.BeginGetContext(GotContext, null);
            rig = TestRig.CreateMultiFile();
            connection = new HttpConnection(new Uri(string.Format(listenerURL, i)));
            connection.Manager = rig.Manager;

            id = new PeerId(new Peer("this is my id", connection.Uri), rig.Manager);
            id.Connection = connection;
            id.IsChoking = false;
            id.AmInterested = true;
            id.BitField.SetAll(true);
            id.MaxPendingRequests = numberOfPieces;
            
            requests = rig.Manager.PieceManager.Picker.PickPiece(id, new List<PeerId>(), numberOfPieces);
        }
开发者ID:Cyarix,项目名称:monotorrent,代码行数:33,代码来源:TestWebSeed.cs

示例6: HttpListenerContext

		internal HttpListenerContext (HttpConnection cnc)
		{
			this.cnc   = cnc;
			err_status = 400;
			request    = new HttpListenerRequest (this);
			response   = new HttpListenerResponse (this);
		}
开发者ID:fengxianqi,项目名称:Youbang,代码行数:7,代码来源:HttpListenerContext.cs

示例7: RemoveConnection

 public void RemoveConnection(HttpConnection connection)
 {
     lock (this._requests)
     {
         this._requests.Remove(connection);
     }
 }
开发者ID:jorgeantwan18,项目名称:rokumedia,代码行数:7,代码来源:HttpServer.cs

示例8: ExecuteTest

 public void ExecuteTest()
 {
     HttpConnection target = new HttpConnection();
     HttpWebRequest httpRequest = GetHttpWebRequest();
     string actual = target.Execute(payLoad, httpRequest);
     Assert.IsNotNull(actual);
 }
开发者ID:hsavran,项目名称:rest-api-sdk-dotnet,代码行数:7,代码来源:HttpConnectionTest.cs

示例9: Client

        public Client(HttpConnection connection)
        {
            _nodeName = Environment.GetEnvironmentVariable("CONSUL_CLIENT_NODE_NAME") ?? "undefined node";
            _serviceName = Environment.GetEnvironmentVariable("CONSUL_CLIENT_SERVICE_NAME") ?? "undefined service";
            _datacenterName = Environment.GetEnvironmentVariable("CONSUL_CLIENT_DATACENTER_NAME") ?? "dc1";

            _catalog = new Catalog(connection);
        }
开发者ID:rtezli,项目名称:consuldotnext,代码行数:8,代码来源:Client.cs

示例10: AspWorkerRequest

//		private bool _headersSent;

		/// <summary>
		/// Initializes a new instance of the AspWorkerRequest class
		/// </summary>
		/// <param name="connection"></param>
		/// <param name="request"></param>
		public AspWorkerRequest(AspHost aspHost, HttpConnection connection, HttpRequest request) : base(string.Empty, string.Empty, null)
		{						
			_aspHost = aspHost;
			_connection = connection;
			_request = request;
			_response = new HttpResponse(new OkStatus());

			this.ParsePathInfo();
		}
开发者ID:FireBall1725,项目名称:Razor.Framework,代码行数:16,代码来源:AspWorkerRequest.cs

示例11: AddressBookItemConnectionManager

		/// <summary>
		/// Initializes a new instance of the AddressBookItemConnectionManager class
		/// </summary>
		/// <param name="item">The address book item that defines the remote host to connect to</param>
		/// <param name="connection">The Tcp connection that will be used throughout the lifetime of the connection</param>
		public AddressBookItemConnectionManager(AddressBookItem item, HttpConnection connection)
		{
			if (item == null)
				throw new ArgumentNullException("item");

			if (connection == null)
				throw new ArgumentNullException("connection");

			_propertyBag = new Hashtable();
			_item = item;
			_connection = connection;
			_connection.Opened += new HttpConnectionEventHandler(OnInternalConnectionOpened);
			_connection.Closed += new HttpConnectionEventHandler(OnInternalConnectionClosed);
			_connection.Exception += new ExceptionEventHandler(OnInternalConnectionException);
		}      
开发者ID:FireBall1725,项目名称:Razor.Framework,代码行数:20,代码来源:AddressBookItemConnectionManager.cs

示例12: NanoHttpRequest

        public NanoHttpRequest(HttpConnection conn, string request)
        {
            Connection = conn;
            if (string.IsNullOrEmpty(request))
            {
                Invalid = true;
                return;
            }

            var fls = request.Split(new char[]{ ' ' }, 3);

            if (fls.Length < 2)
            {
                Invalid = true;
                return;
            }

            Method = fls[0];
            Address = fls[1];

            //if (Method == "POST")
            {
                var heco = request.Split(new string[]{ "\r\n\r\n" }, 2, StringSplitOptions.None);

                if (heco.Length < 2)
                {
                    Invalid = true;
                    return;
                }

                var he = heco[0];
                var co = heco[1];
                Content = co;
                var lines = he.Split(new string[]{ "\r\n", "\n" }, StringSplitOptions.None);

                for (int i = 1; i < lines.Length; i++)
                {
                    var hl = lines[i].Split(new String[]{": "}, 2, StringSplitOptions.None);
                    if (hl.Length < 2) continue;
                    Headers[hl[0]] = hl[1];
                }
            }
        }
开发者ID:Bit-notes,项目名称:nanoboard,代码行数:43,代码来源:NanoHttpRequest.cs

示例13: RequestTimeout

        public void RequestTimeout(HttpConnection connection)
        {
            var param = connection.Param;
            int msgId = param.Get("MsgId").ToInt();
            int actionId = param.Get("ActionId").ToInt();
            int errorCode = LanguageHelper.GetLang().ErrorCode;
            string errorMsg = LanguageHelper.GetLang().RequestTimeout;
            var head = new MessageHead(msgId, actionId, "st", errorCode, errorMsg);
            head.HasGzip = true;
            var ms = new MessageStructure();
            ms.WriteBuffer(head);
            byte[] data = ms.ReadBuffer();

            string remoteAddress = connection.Context.Request.RemoteEndPoint.Address.ToString();
            string successMsg = string.Format("{0}>>发送超时到{1} {2}字节!",
                                              DateTime.Now.ToString("HH:mm:ss:ms"), remoteAddress, data.Length);
            Console.WriteLine(successMsg);
            OnResponseCompleted(connection, data);
        }
开发者ID:rongxiong,项目名称:Scut,代码行数:19,代码来源:HttpTransponder.cs

示例14: Process

        private void Process(HttpConnection connection, NanoHttpRequest request)
        {
            if (request.Address == "/")
            {
                connection.Response(_root.Handle(request));
                return;
            }

            var endpoint = request.Address.Split(new char[]{'/'}, StringSplitOptions.RemoveEmptyEntries)[0];

            if (_handlers.ContainsKey(endpoint))
            {
                connection.Response(_handlers[endpoint].Handle(request));
            }

            else
            {
                connection.Response(new ErrorHandler(StatusCode.BadRequest, "Unknown endpoint: " + endpoint).Handle(request));
            }
        }
开发者ID:Bit-notes,项目名称:nanoboard,代码行数:20,代码来源:NanoHttpServer.cs

示例15: Run

        protected override void Run()
        {
            this._listener.Start();
            while (true)
            {
                try
                {
                    TcpClient client = this._listener.AcceptTcpClient();
                    HttpConnection connection = new HttpConnection(this, client);
                    lock (this._requests)
                    {
                        this._requests.Add(connection);
                    }
                    connection.Start();

                }
                catch {
                
                }
            }
            
        }
开发者ID:jorgeantwan18,项目名称:rokumedia,代码行数:22,代码来源:HttpServer.cs


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