Пример #1
0
        public void Dump(ILogger logger)
        {
            var webRequestProxy = TargetObject;

            var uri = webRequestProxy.Address.Value;

            using (logger.BeginScope(webRequestProxy))
            {
                logger.LogInformation($"uri: {uri}");

                using (logger.BeginScope("Headers"))
                {
                    var headerCollectionAnalyzer = new WebHeaderCollectionAnalyzer(Context, webRequestProxy.Headers);
                    headerCollectionAnalyzer.Dump(logger);
                }

                using (logger.BeginScope("_HttpResponse"))
                {
                    var responseProxy = webRequestProxy.Response;
                    if (responseProxy != null)
                    {
                        var httpWebResponseAnalyzer = new HttpWebResponseAnalyzer(Context, responseProxy);
                        httpWebResponseAnalyzer.Dump(logger);
                    }
                }


//                        var startTimestamp = (long) webRequestObject.Type.GetFieldByName("m_StartTimestamp")
//                            .GetValue(webRequestObject.Address);
//                        var startTime =
//                            TimeSpan.FromTicks(
//                                unchecked((long) (startTimestamp * 4.876196D))); // TODO get tickFrequency;

                //logger.LogInformation($" start = {startTime} ");
                ////                m_Aborted:0x0 (System.Int32)
////                m_OnceFailed:false (System.Boolean)
////                m_Retry:false (System.Boolean)
////                m_BodyStarted:true (System.Boolean)
////                m_RequestSubmitted:true (System.Boolean)
////                m_StartTimestamp:0x8f4548c2db (System.Int64)
////                _HttpResponse:NULL (System.Net.HttpWebResponse)
////                _OriginUri:00000078edcea920 (System.Uri)
            }
        }
Пример #2
0
        public void Dump(ILogger logger)
        {
            var responseProxy = TargetObject;

            logger.LogInformation(responseProxy.TargetObject.ToString());
            logger.LogInformation($"Status: {responseProxy.StatusCode} {responseProxy.StatusDescription}");
            logger.LogInformation($"ContentLength: {responseProxy.ContentLength}");

            var connectStreamObject = responseProxy.TargetObject.ReadObjectField("m_ConnectStream");
            int doneCalled          = -1;

            if (!connectStreamObject.IsNull)
            {
                doneCalled = connectStreamObject.ReadField <int>("m_DoneCalled");

                var readBuffer       = connectStreamObject.ReadObjectField("m_ReadBuffer");
                var readBufferLength = readBuffer.AsArray().Length;
                var startDataAddress = readBuffer.Type.GetArrayElementAddress(readBuffer.Address, 0);

                var buffer = new byte[readBufferLength];

                //throw new NotImplementedException();
                // Context.Heap.ReadMemory(startDataAddress, buffer, 0, readBufferLength);

                var readBufferSize = connectStreamObject.ReadField <int>("m_ReadBufferSize");
                var readOffset     = connectStreamObject.ReadField <int>("m_ReadOffset");

                var s = Encoding.UTF8.GetString(buffer, readOffset, readBufferSize);

                logger.LogInformation($"m_ConnectStream.m_ReadBuffer: {s}");
            }
            logger.LogInformation($"m_ConnectStream.m_DoneCalled: {doneCalled}");

            var headerCollectionAnalyzer = new WebHeaderCollectionAnalyzer(Context, responseProxy.Headers);

            using (logger.BeginScope("Headers"))
            {
                headerCollectionAnalyzer.Dump(logger);
            }
        }