GetRequestStream() public method

public GetRequestStream ( ) : Stream
return Stream
Beispiel #1
0
        } // IServerChannelSink

        internal void ServiceRequest(Object state)
        {
            HttpServerSocketHandler streamManager = (HttpServerSocketHandler)state;

            ITransportHeaders headers       = streamManager.ReadHeaders();
            Stream            requestStream = streamManager.GetRequestStream();

            // process request
            ServerChannelSinkStack sinkStack = new ServerChannelSinkStack();

            sinkStack.Push(this, streamManager);

            IMessage          responseMessage;
            ITransportHeaders responseHeaders;
            Stream            responseStream;

            ServerProcessing processing =
                _nextSink.ProcessMessage(sinkStack, null, headers, requestStream,
                                         out responseMessage,
                                         out responseHeaders, out responseStream);

            // handle response
            switch (processing)
            {
            case ServerProcessing.Complete:
            {
                // Send the response. Call completed synchronously.
                sinkStack.Pop(this);
                streamManager.SendResponse(responseStream, "200", "OK", responseHeaders);
                break;
            } // case ServerProcessing.Complete

            case ServerProcessing.OneWay:
            {
                // Just send back a 200 OK
                streamManager.SendResponse(null, "202", "Accepted", responseHeaders);
                break;
            } // case ServerProcessing.OneWay

            case ServerProcessing.Async:
            {
                sinkStack.StoreAndDispatch(this, streamManager);
                break;
            } // case ServerProcessing.Async
            } // switch (processing)


            // async processing will take care if handling this later
            if (processing != ServerProcessing.Async)
            {
                if (streamManager.CanServiceAnotherRequest())
                {
                    streamManager.BeginReadMessage();
                }
                else
                {
                    streamManager.Close();
                }
            }
        } // ServiceRequest
Beispiel #2
0
        internal void ServiceRequest(object state)
        {
            IMessage                message;
            ITransportHeaders       headers2;
            Stream                  stream2;
            HttpServerSocketHandler handler        = (HttpServerSocketHandler)state;
            ITransportHeaders       requestHeaders = handler.ReadHeaders();
            Stream                  requestStream  = handler.GetRequestStream();

            requestHeaders["__CustomErrorsEnabled"] = handler.CustomErrorsEnabled();
            ServerChannelSinkStack sinkStack = new ServerChannelSinkStack();

            sinkStack.Push(this, handler);
            ServerProcessing processing = this._nextSink.ProcessMessage(sinkStack, null, requestHeaders, requestStream, out message, out headers2, out stream2);

            switch (processing)
            {
            case ServerProcessing.Complete:
                sinkStack.Pop(this);
                handler.SendResponse(stream2, "200", "OK", headers2);
                break;

            case ServerProcessing.OneWay:
                handler.SendResponse(null, "202", "Accepted", headers2);
                break;

            case ServerProcessing.Async:
                sinkStack.StoreAndDispatch(this, handler);
                break;
            }
            if (processing != ServerProcessing.Async)
            {
                if (handler.CanServiceAnotherRequest())
                {
                    handler.BeginReadMessage();
                }
                else
                {
                    handler.Close();
                }
            }
        }