public void ReceiveResponse(out ITransportHeaders responseHeaders, out Stream responseStream) { // transport signature if (!MatchPreamble()) BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidMessageFormat); // operation opcode byte operation = _reader.ReadByte(); if (operation != BinaryWireProtocol.OperationType.Reply) BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidMessageFormat); // content length int contentLength = _reader.ReadInt32(); // response headers responseHeaders = ReadHeaders(); // set special headers responseHeaders[BinaryWireProtocol.WellKnownHeaders.ConnectionId] = _connectionId; // create stream for response reading if (contentLength == -1) { responseStream = new ChunkedReadStream(_bufferedStream); } else { responseStream = new FixedReadStream(_bufferedStream, contentLength); } }
public void ReceiveRequest(out ITransportHeaders requestHeaders, out Stream requestStream) { // transport signature if (!MatchPreamble()) BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidMessageFormat); // operation opcode byte operation = _reader.ReadByte(); if (operation != BinaryWireProtocol.OperationType.Request && operation != BinaryWireProtocol.OperationType.OneWayRequest) BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidMessageFormat); // content length int contentLength = _reader.ReadInt32(); // request uri string requestUri = _reader.ReadString(); if (!CheckRequestUri(requestUri)) BinaryWireProtocol.ThrowException(BinaryWireProtocol.StatusCode.InvalidRequestUri); // request headers requestHeaders = ReadHeaders(); // set special headers requestHeaders[BinaryWireProtocol.WellKnownHeaders.ConnectionId] = _connectionId; requestHeaders[BinaryWireProtocol.WellKnownHeaders.RequestUri] = requestUri; // create stream for request reading if (contentLength == -1) { requestStream = new ChunkedReadStream(_bufferedStream); } else { requestStream = new FixedReadStream(_bufferedStream, contentLength); } // set client principal RemotingService.ClientPrincipal = _transport.ClientPrincipal; }