示例#1
0
        public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, object state,
                                         IMessage msg, ITransportHeaders headers, Stream responseStream)
        {
            ContextWithId ctx = (ContextWithId)state;

            WriteOut(ctx.Context, headers, responseStream);
            ctx.Context.Response.Close();
        }
示例#2
0
        internal void HandleRequest(HttpListenerContext context)
        {
            //build the headers
            ITransportHeaders requestHeaders = new TransportHeaders();

            System.Collections.Specialized.NameValueCollection httpHeaders = context.Request.Headers;
            foreach (string key in httpHeaders.Keys)
            {
                requestHeaders[key] = httpHeaders[key];
            }

            //get an ID for this connection
            ContextWithId identitiedContext = new ContextWithId(context);

            requestHeaders[CommonTransportKeys.RequestUri]   = context.Request.Url.PathAndQuery;
            requestHeaders[CommonTransportKeys.IPAddress]    = context.Request.RemoteEndPoint.Address;
            requestHeaders[CommonTransportKeys.ConnectionId] = identitiedContext.ID;
            requestHeaders["__RequestVerb"] = context.Request.HttpMethod;
            requestHeaders["__HttpVersion"] = string.Format("HTTP/{0}.{1}",
                                                            context.Request.ProtocolVersion.Major, context.Request.ProtocolVersion.Minor);

            if (RemotingConfiguration.CustomErrorsEnabled(context.Request.IsLocal))
            {
                requestHeaders["__CustomErrorsEnabled"] = false;
            }

            IMessage          responseMsg;
            Stream            responseStream;
            ITransportHeaders responseHeaders;

            // attach the context as state so that our async handler can use it to send the response
            ServerChannelSinkStack sinkStack = new ServerChannelSinkStack();

            sinkStack.Push(this, identitiedContext);

            // NOTE: if we copy the InputStream before passing it so the sinks, the .NET formatters have
            // unspecified internal errors. Let's hope they don't need to seek the stream!
            ServerProcessing proc = nextSink.ProcessMessage(sinkStack, null, requestHeaders, context.Request.InputStream,
                                                            out responseMsg, out responseHeaders, out responseStream);

            switch (proc)
            {
            case ServerProcessing.Complete:
                WriteOut(context, responseHeaders, responseStream);
                context.Response.Close();
                break;

            case ServerProcessing.Async:
                break;

            case ServerProcessing.OneWay:
                context.Response.Close();
                break;
            }
        }
示例#3
0
        internal ServerProcessing SynchronousDispatch(ITransportHeaders requestHeaders, Stream requestStream,
                                                      out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            IMessage      responseMsg;
            ContextWithId identitiedContext = new ContextWithId(null);

            // attach the context as state so that our async handler can use it to send the response
            ServerChannelSinkStack sinkStack = new ServerChannelSinkStack();

            sinkStack.Push(this, identitiedContext);

            return(nextSink.ProcessMessage(sinkStack, null, requestHeaders, requestStream,
                                           out responseMsg, out responseHeaders, out responseStream));
        }
示例#4
0
		internal void HandleRequest (HttpListenerContext context)
		{
			//build the headers
			ITransportHeaders requestHeaders = new TransportHeaders ();
			System.Collections.Specialized.NameValueCollection httpHeaders = context.Request.Headers;
			foreach (string key in httpHeaders.Keys) {
				requestHeaders[key] = httpHeaders[key];
			}

			//get an ID for this connection
			ContextWithId identitiedContext = new ContextWithId (context);

			requestHeaders[CommonTransportKeys.RequestUri] = context.Request.Url.PathAndQuery;
			requestHeaders[CommonTransportKeys.IPAddress] = context.Request.RemoteEndPoint.Address;
			requestHeaders[CommonTransportKeys.ConnectionId] = identitiedContext.ID;
			requestHeaders["__RequestVerb"] = context.Request.HttpMethod;
			requestHeaders["__HttpVersion"] = string.Format ("HTTP/{0}.{1}",
				context.Request.ProtocolVersion.Major, context.Request.ProtocolVersion.Minor);

			if (RemotingConfiguration.CustomErrorsEnabled (context.Request.IsLocal))
				requestHeaders["__CustomErrorsEnabled"] = false;

			IMessage responseMsg;
			Stream responseStream;
			ITransportHeaders responseHeaders;
			
			// attach the context as state so that our async handler can use it to send the response
			ServerChannelSinkStack sinkStack = new ServerChannelSinkStack ();
			sinkStack.Push (this, identitiedContext);

			// NOTE: if we copy the InputStream before passing it so the sinks, the .NET formatters have 
			// unspecified internal errors. Let's hope they don't need to seek the stream!
			ServerProcessing proc = nextSink.ProcessMessage (sinkStack, null, requestHeaders, context.Request.InputStream, 
				out responseMsg, out responseHeaders, out responseStream);
			
			switch (proc) {
			case ServerProcessing.Complete:
				WriteOut (context, responseHeaders, responseStream);
				context.Response.Close ();
				break;

			case ServerProcessing.Async:
				break;

			case ServerProcessing.OneWay:
				context.Response.Close ();
				break;
			}

		}
示例#5
0
		internal ServerProcessing SynchronousDispatch (ITransportHeaders requestHeaders, Stream requestStream,
			out ITransportHeaders responseHeaders, out Stream responseStream)
		{
			IMessage responseMsg;
			ContextWithId identitiedContext = new ContextWithId (null);
			
			// attach the context as state so that our async handler can use it to send the response
			ServerChannelSinkStack sinkStack = new ServerChannelSinkStack ();
			sinkStack.Push (this, identitiedContext);
			
			return nextSink.ProcessMessage (sinkStack, null, requestHeaders, requestStream, 
				out responseMsg, out responseHeaders, out responseStream);
		}