} // SendContinue

        public void SendResponse(Stream httpContentStream,
                                 String statusCode, String reasonPhrase,
                                 ITransportHeaders headers)
        {
            if (_responseStream != null)
            {
                _responseStream.Close();
                if (_responseStream != httpContentStream)
                {
                    throw new RemotingException(
                              CoreChannel.GetResourceString("Remoting_Http_WrongResponseStream"));
                }

                // we are done with the response stream
                _responseStream = null;
            }
            else
            {
                if (headers == null)
                {
                    headers = new TransportHeaders();
                }

                String serverHeader = (String)headers["Server"];
                if (serverHeader != null)
                {
                    serverHeader = HttpServerTransportSink.ServerHeader + ", " + serverHeader;
                }
                else
                {
                    serverHeader = HttpServerTransportSink.ServerHeader;
                }
                headers["Server"] = serverHeader;

                // Add length to response headers if necessary
                if (!AllowChunkedResponse && (httpContentStream != null))
                {
                    headers["Content-Length"] = httpContentStream.Length.ToString(CultureInfo.InvariantCulture);
                }
                else
                if (httpContentStream == null)
                {
                    headers["Content-Length"] = "0";
                }

                GetResponseStream(statusCode, reasonPhrase, headers);

                // write HTTP content
                if (httpContentStream != null)
                {
                    StreamHelper.CopyStream(httpContentStream, _responseStream);

                    _responseStream.Close();
                    httpContentStream.Close();
                }

                // we are done with the response stream
                _responseStream = null;
            }
        } // SendResponse
Пример #2
0
        } // SendContinue

        public void SendResponse(Stream httpContentStream,
                                 String statusCode, String reasonPhrase,
                                 ITransportHeaders headers)
        {
            if (_responseStream != null)
            {
                _responseStream.Close();
                if (_responseStream != httpContentStream)
                {
                    throw new RemotingException(
                              "Http transport sink was not given the stream that it returned from GetResponseStream().");
                }

                // we are done with the response stream
                _responseStream = null;
            }
            else
            {
                if (headers == null)
                {
                    headers = new TransportHeaders();
                }

                String serverHeader = (String)headers["Server"];
                if (serverHeader != null)
                {
                    serverHeader = HttpServerTransportSink.ServerHeader + ", " + serverHeader;
                }
                else
                {
                    serverHeader = HttpServerTransportSink.ServerHeader;
                }
                headers["Server"] = serverHeader;

                // Add length to response headers if necessary
                if (!AllowChunkedResponse && (httpContentStream != null))
                {
                    headers["Content-Length"] = httpContentStream.Length.ToString();
                }
                else
                if (httpContentStream == null)
                {
                    headers["Content-Length"] = "0";
                }

                GetResponseStream(statusCode, reasonPhrase, headers);

                // write HTTP content
                if (httpContentStream != null)
                {
                    StreamHelper.CopyStream(httpContentStream, _responseStream);

                    _responseStream.Close();
                    httpContentStream.Close();
                }

                // we are done with the response stream
                _responseStream = null;
            }
        } // SendResponse
 protected override void PrepareForNewMessage()
 {
     this._requestStream   = null;
     this._responseStream  = null;
     this._contentLength   = 0;
     this._chunkedEncoding = false;
     this._keepAlive       = false;
 }
Пример #4
0
        } // CanServiceAnotherRequest

        // Prepare for reading a new request off of the same socket
        protected override void PrepareForNewMessage()
        {
            _requestStream  = null;
            _responseStream = null;

            _contentLength        = 0;
            _chunkedEncoding      = false;
            _keepAlive            = false;
            _allowChunkedResponse = false;
        } // PrepareForNewRequest
        public Stream GetResponseStream(string statusCode, string reasonPhrase, ITransportHeaders headers)
        {
            bool   flag   = false;
            bool   flag2  = false;
            int    length = 0;
            object obj2   = headers["__HttpStatusCode"];
            string str    = headers["__HttpReasonPhrase"] as string;

            if (obj2 != null)
            {
                statusCode = obj2.ToString();
            }
            if (str != null)
            {
                reasonPhrase = str;
            }
            if (!this.CanServiceAnotherRequest())
            {
                headers["Connection"] = "Close";
            }
            object obj3 = headers["Content-Length"];

            if (obj3 != null)
            {
                flag = true;
                if (obj3 is int)
                {
                    length = (int)obj3;
                }
                else
                {
                    length = Convert.ToInt32(obj3, CultureInfo.InvariantCulture);
                }
            }
            flag2 = this.AllowChunkedResponse && !flag;
            if (flag2)
            {
                headers["Transfer-Encoding"] = "chunked";
            }
            ChunkedMemoryStream outputStream = new ChunkedMemoryStream(CoreChannel.BufferPool);

            base.WriteResponseFirstLine(statusCode, reasonPhrase, outputStream);
            base.WriteHeaders(headers, outputStream);
            outputStream.WriteTo(base.NetStream);
            outputStream.Close();
            if (flag2)
            {
                this._responseStream = new HttpChunkedResponseStream(base.NetStream);
            }
            else
            {
                this._responseStream = new HttpFixedLengthResponseStream(base.NetStream, length);
            }
            return(this._responseStream);
        }
 public void SendResponse(Stream httpContentStream, string statusCode, string reasonPhrase, ITransportHeaders headers)
 {
     if (this._responseStream != null)
     {
         this._responseStream.Close();
         if (this._responseStream != httpContentStream)
         {
             throw new RemotingException(CoreChannel.GetResourceString("Remoting_Http_WrongResponseStream"));
         }
         this._responseStream = null;
     }
     else
     {
         if (headers == null)
         {
             headers = new TransportHeaders();
         }
         string serverHeader = (string)headers["Server"];
         if (serverHeader != null)
         {
             serverHeader = HttpServerTransportSink.ServerHeader + ", " + serverHeader;
         }
         else
         {
             serverHeader = HttpServerTransportSink.ServerHeader;
         }
         headers["Server"] = serverHeader;
         if (!this.AllowChunkedResponse && (httpContentStream != null))
         {
             headers["Content-Length"] = httpContentStream.Length.ToString(CultureInfo.InvariantCulture);
         }
         else if (httpContentStream == null)
         {
             headers["Content-Length"] = "0";
         }
         this.GetResponseStream(statusCode, reasonPhrase, headers);
         if (httpContentStream != null)
         {
             StreamHelper.CopyStream(httpContentStream, this._responseStream);
             this._responseStream.Close();
             httpContentStream.Close();
         }
         this._responseStream = null;
     }
 }
 public Stream GetResponseStream(string statusCode, string reasonPhrase, ITransportHeaders headers)
 {
     bool flag = false;
     bool flag2 = false;
     int length = 0;
     object obj2 = headers["__HttpStatusCode"];
     string str = headers["__HttpReasonPhrase"] as string;
     if (obj2 != null)
     {
         statusCode = obj2.ToString();
     }
     if (str != null)
     {
         reasonPhrase = str;
     }
     if (!this.CanServiceAnotherRequest())
     {
         headers["Connection"] = "Close";
     }
     object obj3 = headers["Content-Length"];
     if (obj3 != null)
     {
         flag = true;
         if (obj3 is int)
         {
             length = (int) obj3;
         }
         else
         {
             length = Convert.ToInt32(obj3, CultureInfo.InvariantCulture);
         }
     }
     flag2 = this.AllowChunkedResponse && !flag;
     if (flag2)
     {
         headers["Transfer-Encoding"] = "chunked";
     }
     ChunkedMemoryStream outputStream = new ChunkedMemoryStream(CoreChannel.BufferPool);
     base.WriteResponseFirstLine(statusCode, reasonPhrase, outputStream);
     base.WriteHeaders(headers, outputStream);
     outputStream.WriteTo(base.NetStream);
     outputStream.Close();
     if (flag2)
     {
         this._responseStream = new HttpChunkedResponseStream(base.NetStream);
     }
     else
     {
         this._responseStream = new HttpFixedLengthResponseStream(base.NetStream, length);
     }
     return this._responseStream;
 }
 public void SendResponse(Stream httpContentStream, string statusCode, string reasonPhrase, ITransportHeaders headers)
 {
     if (this._responseStream != null)
     {
         this._responseStream.Close();
         if (this._responseStream != httpContentStream)
         {
             throw new RemotingException(CoreChannel.GetResourceString("Remoting_Http_WrongResponseStream"));
         }
         this._responseStream = null;
     }
     else
     {
         if (headers == null)
         {
             headers = new TransportHeaders();
         }
         string serverHeader = (string) headers["Server"];
         if (serverHeader != null)
         {
             serverHeader = HttpServerTransportSink.ServerHeader + ", " + serverHeader;
         }
         else
         {
             serverHeader = HttpServerTransportSink.ServerHeader;
         }
         headers["Server"] = serverHeader;
         if (!this.AllowChunkedResponse && (httpContentStream != null))
         {
             headers["Content-Length"] = httpContentStream.Length.ToString(CultureInfo.InvariantCulture);
         }
         else if (httpContentStream == null)
         {
             headers["Content-Length"] = "0";
         }
         this.GetResponseStream(statusCode, reasonPhrase, headers);
         if (httpContentStream != null)
         {
             StreamHelper.CopyStream(httpContentStream, this._responseStream);
             this._responseStream.Close();
             httpContentStream.Close();
         }
         this._responseStream = null;
     }
 }
 protected override void PrepareForNewMessage()
 {
     this._requestStream = null;
     this._responseStream = null;
     this._contentLength = 0;
     this._chunkedEncoding = false;
     this._keepAlive = false;
 }
Пример #10
0
        } // SendContinue
 

        public void SendResponse(Stream httpContentStream,
                                 String statusCode, String reasonPhrase,
                                 ITransportHeaders headers) 
        {
            if (_responseStream != null) 
            { 
                _responseStream.Close();
                if (_responseStream != httpContentStream) 
                {
                    throw new RemotingException(
                                 CoreChannel.GetResourceString("Remoting_Http_WrongResponseStream"));
                } 

                // we are done with the response stream 
                _responseStream = null; 
            }
            else 
            {
                if (headers == null)
                    headers = new TransportHeaders();
 
                String serverHeader = (String)headers["Server"];
                if (serverHeader != null) 
                    serverHeader = HttpServerTransportSink.ServerHeader + ", " + serverHeader; 
                else
                    serverHeader = HttpServerTransportSink.ServerHeader; 
                headers["Server"] = serverHeader;

                // Add length to response headers if necessary
                if (!AllowChunkedResponse && (httpContentStream != null)) 
                    headers["Content-Length"] = httpContentStream.Length.ToString(CultureInfo.InvariantCulture);
                else 
                if (httpContentStream == null) 
                    headers["Content-Length"] = "0";
 
                GetResponseStream(statusCode, reasonPhrase, headers);

                // write HTTP content
                if(httpContentStream != null) 
                {
                    StreamHelper.CopyStream(httpContentStream, _responseStream); 
 
                    _responseStream.Close();
                    httpContentStream.Close(); 
                }

                // we are done with the response stream
                _responseStream = null; 
            }
        } // SendResponse 
Пример #11
0
        } // GetRequestStream

 
        public Stream GetResponseStream(String statusCode, String reasonPhrase,
                                        ITransportHeaders headers) 
        { 
            bool contentLengthPresent = false;
            bool useChunkedEncoding = false; 
            int contentLength = 0;

            // check for custom user status code and reason phrase
            Object userStatusCode = headers["__HttpStatusCode"]; // someone might have stored an int 
            String userReasonPhrase = headers["__HttpReasonPhrase"] as String;
 
            if (userStatusCode != null) 
                statusCode = userStatusCode.ToString();
            if (userReasonPhrase != null) 
                reasonPhrase = userReasonPhrase;

            // see if we can handle any more requests on this socket
            if (!CanServiceAnotherRequest()) 
            {
                headers["Connection"] = "Close"; 
            } 

            // check for content length 
            Object contentLengthEntry = headers["Content-Length"];
            if (contentLengthEntry != null)
            {
                contentLengthPresent = true; 
                if (contentLengthEntry is int)
                    contentLength = (int)contentLengthEntry; 
                else 
                    contentLength = Convert.ToInt32(contentLengthEntry, CultureInfo.InvariantCulture);
            } 

            // see if we are going to use chunked-encoding
            useChunkedEncoding = AllowChunkedResponse && !contentLengthPresent;
            if (useChunkedEncoding) 
                headers["Transfer-Encoding"] = "chunked";
 
 
            // write headers to stream
            ChunkedMemoryStream headerStream = new ChunkedMemoryStream(CoreChannel.BufferPool); 
            WriteResponseFirstLine(statusCode, reasonPhrase, headerStream);
            WriteHeaders(headers, headerStream);

            headerStream.WriteTo(NetStream); 
            headerStream.Close();
 
 
            // return stream ready for content
            if (useChunkedEncoding) 
                _responseStream = new HttpChunkedResponseStream(NetStream);
            else
                _responseStream = new HttpFixedLengthResponseStream(NetStream, contentLength);
 
            return _responseStream;
        } // GetResponseStream 
Пример #12
0
        } // GetRequestStream

        public Stream GetResponseStream(String statusCode, String reasonPhrase,
                                        ITransportHeaders headers)
        {
            bool contentLengthPresent = false;
            bool useChunkedEncoding   = false;
            int  contentLength        = 0;

            // check for custom user status code and reason phrase
            Object userStatusCode   = headers["__HttpStatusCode"]; // someone might have stored an int
            String userReasonPhrase = headers["__HttpReasonPhrase"] as String;

            if (userStatusCode != null)
            {
                statusCode = userStatusCode.ToString();
            }
            if (userReasonPhrase != null)
            {
                reasonPhrase = userReasonPhrase;
            }

            // see if we can handle any more requests on this socket
            if (!CanServiceAnotherRequest())
            {
                headers["Connection"] = "Close";
            }

            // check for content length
            Object contentLengthEntry = headers["Content-Length"];

            if (contentLengthEntry != null)
            {
                contentLengthPresent = true;
                if (contentLengthEntry is int)
                {
                    contentLength = (int)contentLengthEntry;
                }
                else
                {
                    contentLength = Convert.ToInt32(contentLengthEntry);
                }
            }

            // see if we are going to use chunked-encoding
            useChunkedEncoding = AllowChunkedResponse && !contentLengthPresent;
            if (useChunkedEncoding)
            {
                headers["Transfer-Encoding"] = "chunked";
            }


            // write headers to stream
            ChunkedMemoryStream headerStream = new ChunkedMemoryStream(CoreChannel.BufferPool);

            WriteResponseFirstLine(statusCode, reasonPhrase, headerStream);
            WriteHeaders(headers, headerStream);

            headerStream.WriteTo(NetStream);
            headerStream.Close();


            // return stream ready for content
            if (useChunkedEncoding)
            {
                _responseStream = new HttpChunkedResponseStream(NetStream);
            }
            else
            {
                _responseStream = new HttpFixedLengthResponseStream(NetStream, contentLength);
            }

            return(_responseStream);
        } // GetResponseStream
Пример #13
0
        } // SendContinue


        public void SendResponse(Stream httpContentStream, 
                                 String statusCode, String reasonPhrase,
                                 ITransportHeaders headers)
        {
            if (_responseStream != null)
            {
                _responseStream.Close();
                if (_responseStream != httpContentStream)
                {
                    throw new RemotingException(
                        "Http transport sink was not given the stream that it returned from GetResponseStream().");
                }

                // we are done with the response stream
                _responseStream = null;
            }
            else
            {
                if (headers == null)
                    headers = new TransportHeaders();

                String serverHeader = (String)headers["Server"];
                if (serverHeader != null)
                    serverHeader = HttpServerTransportSink.ServerHeader + ", " + serverHeader;
                else
                    serverHeader = HttpServerTransportSink.ServerHeader;
                headers["Server"] = serverHeader;
            
                // Add length to response headers if necessary
                if (!AllowChunkedResponse && (httpContentStream != null))
                    headers["Content-Length"] = httpContentStream.Length.ToString();
                else
                if (httpContentStream == null)
                    headers["Content-Length"] = "0";
            
                GetResponseStream(statusCode, reasonPhrase, headers);
        
                // write HTTP content
                if(httpContentStream != null)
                {
                    StreamHelper.CopyStream(httpContentStream, _responseStream);                    

                    _responseStream.Close();
                    httpContentStream.Close();
                }

                // we are done with the response stream
                _responseStream = null;
            }
        } // SendResponse
Пример #14
0
        } // CanServiceAnotherRequest
        

        // Prepare for reading a new request off of the same socket
        protected override void PrepareForNewMessage()
        {
            _requestStream = null;
            _responseStream = null;
            
            _contentLength = 0;
            _chunkedEncoding = false;
            _keepAlive = false; 
            _allowChunkedResponse = false;
        } // PrepareForNewRequest