Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal void Complete(ProxyResponse response)
        {
            if (response.Completable && (response.header_ != null))
            {
                string header   = response.header_;
                string contents = response.contents_;

                byte[] headerBytes   = null;
                byte[] contentsBytes = new byte[0];
                if (contents != null)
                {
                    contentsBytes = response.encoding_.GetBytes(contents);
                    header       += "\r\nContent-Length: " + Convert.ToString(contentsBytes.Length) + "\r\n\r\n";
                    headerBytes   = wwwProxy_.defaultEncoding_.GetBytes(header);
                }

                wwwProxy_.log_.Write("Outbound.Complete()", header + ((contents != null) ? contents : ""));

                byte[] responseBytes = new byte[headerBytes.Length + contentsBytes.Length];

                Array.Copy(headerBytes, 0, responseBytes, 0, headerBytes.Length);
                Array.Copy(contentsBytes, 0, responseBytes, headerBytes.Length, contentsBytes.Length);

                inbound_.StopKeepAliveTimer();

                try
                {
                    inbound_.Send(responseBytes, 0, responseBytes.Length);
                }
                catch (IOException)
                {
                }
                catch (ObjectDisposedException)
                {
                }
                catch (SocketException)
                {
                }
            }

            if (responseCloseInbound_)
            {
                inbound_.Close();
            }

            if (completableResponse_)
            {
                completableResponse_  = false;
                responseCloseInbound_ = false;
            }

            response_ = null;
        }
Пример #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal void OnDisconnect(Inbound inbound)
        {
            inbound.Close();

            currentInboundListMutex_.WaitOne();
            currentInboundList_.Remove(inbound);
            currentInboundListMutex_.ReleaseMutex();
        }