Ejemplo n.º 1
0
        // As Client
        private RequestHandshake createOpeningHandshake()
        {
            var path = _uri.PathAndQuery;
            var host = _uri.Port == 80
               ? _uri.DnsSafeHost
               : _uri.Authority;

            var req = new RequestHandshake(path);

            req.AddHeader("Host", host);
            req.AddHeader("Sec-WebSocket-Key", _base64key);
            if (!_protocols.IsNullOrEmpty())
            {
                req.AddHeader("Sec-WebSocket-Protocol", _protocols);
            }
            req.AddHeader("Sec-WebSocket-Version", _version);

            return(req);
        }
Ejemplo n.º 2
0
        // As Client
        private RequestHandshake createOpeningHandshake()
        {
            var path = _uri.PathAndQuery;
            var host = _uri.DnsSafeHost;
            var port = ((System.Net.IPEndPoint)_tcpClient.Client.RemoteEndPoint).Port;

            if (port != 80)
            {
                host += ":" + port;
            }

            var req = new RequestHandshake(path);

            req.AddHeader("Host", host);
            req.AddHeader("Sec-WebSocket-Key", _base64key);
            if (!Ext.IsNullOrEmpty(_protocols))
            {
                req.AddHeader("Sec-WebSocket-Protocol", _protocols);
            }
            req.AddHeader("Sec-WebSocket-Version", _version);
            if (!string.IsNullOrEmpty(this._origin))
            {
                req.AddHeader("Origin", this._origin);
            }
            //extra headers
            if (this.ExtraHeaders != null)
            {
                foreach (var i in this.ExtraHeaders)
                {
                    req.AddHeader(i.Key, i.Value);
                }
            }

            return(req);
        }
Ejemplo n.º 3
0
        // As Client
        private RequestHandshake createOpeningHandshake()
        {
            var path = _uri.PathAndQuery;
            var host = _uri.DnsSafeHost;
            var port = ((System.Net.IPEndPoint)_tcpClient.Client.RemoteEndPoint).Port;

            if (port != 80)
            {
                host += ":" + port;
            }

            var req = new RequestHandshake(path);

            req.AddHeader("Host", host);
            req.AddHeader("Sec-WebSocket-Key", _base64key);
            if (!_protocols.IsNullOrEmpty())
            {
                req.AddHeader("Sec-WebSocket-Protocol", _protocols);
            }
            req.AddHeader("Sec-WebSocket-Version", _version);

            return(req);
        }
Ejemplo n.º 4
0
        // As client
        private RequestHandshake createRequestHandshake()
        {
            var path = _uri.PathAndQuery;
              var host = _uri.Port == 80
               ? _uri.DnsSafeHost
               : _uri.Authority;

              var req = new RequestHandshake(path);
              req.AddHeader("Host", host);

              if (_origin.Length > 0)
            req.AddHeader("Origin", _origin);

              req.AddHeader("Sec-WebSocket-Key", _base64key);

              if (!_protocols.IsNullOrEmpty())
            req.AddHeader("Sec-WebSocket-Protocol", _protocols);

              var extensions = createRequestExtensions();
              if (extensions.Length > 0)
            req.AddHeader("Sec-WebSocket-Extensions", extensions);

              req.AddHeader("Sec-WebSocket-Version", _version);

              if (_preAuth && _credentials != null)
            req.SetAuthorization(new AuthenticationResponse(_credentials));

              if (_cookies.Count > 0)
            req.SetCookies(_cookies);

              return req;
        }
Ejemplo n.º 5
0
        // As Client
        private RequestHandshake createOpeningHandshake()
        {
            var path = _uri.PathAndQuery;
            var host = _uri.DnsSafeHost;
            var port = ((System.Net.IPEndPoint)_tcpClient.Client.RemoteEndPoint).Port;
            if (port != 80)
                host += ":" + port;

            var req = new RequestHandshake(path);
            req.AddHeader("Host", host);
            req.AddHeader("Sec-WebSocket-Key", _base64key);
            if (!Ext.IsNullOrEmpty(_protocols))
                req.AddHeader("Sec-WebSocket-Protocol", _protocols);
            req.AddHeader("Sec-WebSocket-Version", _version);
            if (!string.IsNullOrEmpty(this._origin))
                req.AddHeader("Origin", this._origin);
            //extra headers
            if (this.ExtraHeaders != null)
                foreach (var i in this.ExtraHeaders)
                    req.AddHeader(i.Key, i.Value);

            return req;
        }
Ejemplo n.º 6
0
        // As Client
        private RequestHandshake createOpeningHandshake()
        {
            var path = _uri.PathAndQuery;
              var host = _uri.DnsSafeHost;
              var port = ((System.Net.IPEndPoint)_tcpClient.Client.RemoteEndPoint).Port;
              if (port != 80)
            host += ":" + port;

              var req = new RequestHandshake(path);
              req.AddHeader("Host", host);
              req.AddHeader("Sec-WebSocket-Key", _base64key);
              if (!_protocols.IsNullOrEmpty())
            req.AddHeader("Sec-WebSocket-Protocol", _protocols);
              req.AddHeader("Sec-WebSocket-Version", _version);

              return req;
        }
Ejemplo n.º 7
0
        // As client
        private RequestHandshake createRequestHandshake()
        {
            var path = _uri.PathAndQuery;
              var host = _uri.Port == 80
               ? _uri.DnsSafeHost
               : _uri.Authority;

              var req = new RequestHandshake(path);
              req.AddHeader("Host", host);
              req.AddHeader("Sec-WebSocket-Key", _base64key);
              if (!_protocols.IsNullOrEmpty())
            req.AddHeader("Sec-WebSocket-Protocol", _protocols);
              req.AddHeader("Sec-WebSocket-Version", _version);
              if (_cookies.Count > 0)
            req.SetCookies(_cookies);

              return req;
        }