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); }
public void ThrowArgumentNullException_WhenHeaderIsNull(TransferProtocolReceiver protocol, TransferProtocolReceiverVefify protocolVerify) { Func <Task> action = async() => await protocol.SendResponseAsync(null, _anyByte); action.Should().Throw <ArgumentNullException>(); }
public void ThrowArgumentNullException_WhenContentIsEmpty(TransferProtocolReceiver protocol, TransferProtocolReceiverVefify protocolVerify) { Func <Task> action = async() => await protocol.SendResponseAsync(DefaultStatusHeadersKeyValues, new byte[0]); action.Should().Throw <ArgumentNullException>(); }
public async Task SendResponse(TransferProtocolReceiver protocol, TransferProtocolReceiverVefify protocolVerify) { await protocol.SendResponseAsync(DefaultStatusHeadersKeyValues, _anyByte); protocolVerify.DrainResponse(); }