示例#1
0
        internal async Task HandleIncomingStream()
        {
            var requestBytes = await _protocolReceiver.ReadRequestAsync();

            var functionName = await _protocolReceiver.GetRequestFunctionAsync();

            //TODO: replace with right server actions (below for sample only)
            //Console.WriteLine($"Function to call: {functionName}");
            //Console.WriteLine($"req message: {Encoding.ASCII.GetString(requestBytes)}");
            byte[] responseBytes = Encoding.ASCII.GetBytes("hello world");
            var    headers       = new Dictionary <string, string>
            {
                { ":status", "200" },
                { "info", "pass" }
            };
            await _protocolReceiver.SendResponseAsync(headers, responseBytes);
        }
示例#2
0
        public void ThrowArgumentNullException_WhenHeaderIsNull(TransferProtocolReceiver protocol, TransferProtocolReceiverVefify protocolVerify)
        {
            Func <Task> action = async() => await protocol.SendResponseAsync(null, _anyByte);

            action.Should().Throw <ArgumentNullException>();
        }
示例#3
0
        public void ThrowArgumentNullException_WhenContentIsEmpty(TransferProtocolReceiver protocol, TransferProtocolReceiverVefify protocolVerify)
        {
            Func <Task> action = async() => await protocol.SendResponseAsync(DefaultStatusHeadersKeyValues, new byte[0]);

            action.Should().Throw <ArgumentNullException>();
        }
示例#4
0
        public async Task SendResponse(TransferProtocolReceiver protocol, TransferProtocolReceiverVefify protocolVerify)
        {
            await protocol.SendResponseAsync(DefaultStatusHeadersKeyValues, _anyByte);

            protocolVerify.DrainResponse();
        }