当前位置: 首页>>代码示例>>C#>>正文


C# SessionEventArgs.Dispose方法代码示例

本文整理汇总了C#中SessionEventArgs.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SessionEventArgs.Dispose方法的具体用法?C# SessionEventArgs.Dispose怎么用?C# SessionEventArgs.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionEventArgs的用法示例。


在下文中一共展示了SessionEventArgs.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Dispose

        private static void Dispose(TcpClient client, Stream clientStream, CustomBinaryReader clientStreamReader, StreamWriter clientStreamWriter, SessionEventArgs args)
        {
            if (args != null)
                args.Dispose();

            if (clientStreamReader != null)
                clientStreamReader.Dispose();

            if (clientStreamWriter != null)
                clientStreamWriter.Dispose();

            if (clientStream != null)
                clientStream.Dispose();

            if (client != null)
                client.Close();
        }
开发者ID:amitla,项目名称:Titanium,代码行数:17,代码来源:ResponseHandler.cs

示例2: HandleHttpSessionResponse

        //Called asynchronously when a request was successfully and we received the response
        private static void HandleHttpSessionResponse(SessionEventArgs args)
        {
            args.ProxySession.ReceiveResponse();

            try
            {

                args.ProxySession.Response.ResponseHeaders = ReadResponseHeaders(args.ProxySession);
                args.ProxySession.Response.ResponseStream = args.ProxySession.ProxyClient.ServerStreamReader.BaseStream;


                if (BeforeResponse != null)
                {
                    args.ProxySession.Response.Encoding = args.ProxySession.GetResponseEncoding();
                    BeforeResponse(null, args);
                }

                args.ProxySession.Response.ResponseLocked = true;

                if (args.ProxySession.Response.ResponseBodyRead)
                {
                    var isChunked = args.ProxySession.Response.IsChunked;
                    var contentEncoding = args.ProxySession.Response.ContentEncoding;

                    if(contentEncoding!=null)
                    switch (contentEncoding)
                    {
                        case "gzip":
                            args.ProxySession.Response.ResponseBody = CompressionHelper.CompressGzip(args.ProxySession.Response.ResponseBody);
                            break;
                        case "deflate":
                            args.ProxySession.Response.ResponseBody = CompressionHelper.CompressDeflate(args.ProxySession.Response.ResponseBody);
                            break;
                        case "zlib":
                            args.ProxySession.Response.ResponseBody = CompressionHelper.CompressZlib(args.ProxySession.Response.ResponseBody);
                            break;
                    }

                    WriteResponseStatus(args.ProxySession.Response.HttpVersion, args.ProxySession.Response.ResponseStatusCode,
                        args.ProxySession.Response.ResponseStatusDescription, args.Client.ClientStreamWriter);
                    WriteResponseHeaders(args.Client.ClientStreamWriter, args.ProxySession.Response.ResponseHeaders, args.ProxySession.Response.ResponseBody.Length,
                        isChunked);
                    WriteResponseBody(args.Client.ClientStream, args.ProxySession.Response.ResponseBody, isChunked);
                }
                else
                {
                    WriteResponseStatus(args.ProxySession.Response.HttpVersion, args.ProxySession.Response.ResponseStatusCode,
                         args.ProxySession.Response.ResponseStatusDescription, args.Client.ClientStreamWriter);
                    WriteResponseHeaders(args.Client.ClientStreamWriter, args.ProxySession.Response.ResponseHeaders);

                    if (args.ProxySession.Response.IsChunked || args.ProxySession.Response.ContentLength > 0)
                        WriteResponseBody(args.ProxySession.ProxyClient.ServerStreamReader, args.Client.ClientStream, args.ProxySession.Response.IsChunked, args.ProxySession.Response.ContentLength);
                }

                args.Client.ClientStream.Flush();

            }
            catch
            {
                Dispose(args.Client.TcpClient, args.Client.ClientStream, args.Client.ClientStreamReader, args.Client.ClientStreamWriter, args);
            }
            finally
            {
                args.Dispose();
            }
        }
开发者ID:davidchiew,项目名称:Titanium-Web-Proxy,代码行数:67,代码来源:ResponseHandler.cs


注:本文中的SessionEventArgs.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。