Пример #1
0
        public void HttpUpgradeRequestInvalidUpgradeHeader()
        {
            EmbeddedChannel  ch = this.CreateChannel();
            IFullHttpRequest httpRequestWithEntity = new WebSocketRequestBuilder()
                                                     .HttpVersion(Http11)
                                                     .Method(HttpMethod.Get)
                                                     .Uri("/test")
                                                     .Connection("Upgrade")
                                                     .Version00()
                                                     .Upgrade("BogusSocket")
                                                     .Build();

            ch.WriteInbound(httpRequestWithEntity);

            IFullHttpResponse response = this.responses.Dequeue();

            Assert.Equal(BadRequest, response.Status);
            Assert.Equal("not a WebSocket handshake request: missing upgrade", GetResponseMessage(response));
            response.Release();
        }
Пример #2
0
        public void HttpUpgradeRequestMissingWsKeyHeader()
        {
            EmbeddedChannel ch          = this.CreateChannel();
            IHttpRequest    httpRequest = new WebSocketRequestBuilder()
                                          .HttpVersion(Http11)
                                          .Method(HttpMethod.Get)
                                          .Uri("/test")
                                          .Key(null)
                                          .Connection("Upgrade")
                                          .Upgrade(HttpHeaderValues.Websocket)
                                          .Version13()
                                          .Build();

            ch.WriteInbound(httpRequest);

            IFullHttpResponse response = this.responses.Dequeue();

            Assert.Equal(BadRequest, response.Status);
            Assert.Equal("not a WebSocket request: missing key", GetResponseMessage(response));
            response.Release();
        }
Пример #3
0
 static void WriteUpgradeRequest(EmbeddedChannel ch) => ch.WriteInbound(WebSocketRequestBuilder.Successful());