protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            
//            var messageId = Guid.NewGuid();
            var runscopeRequest = new RunscopeRequest(request);  // Preread to ensure non-rewindable stream is not consumed by app

            //var runscopeMessage = new RunscopeMessage()
            //{
            //    UniqueIdentifier = messageId,
            //    Request = runscopeRequest
            //};

//            HandleFailedMessageLog(_RunscopeClient.SendAsync(messagesLink.Update(_bucketKey, runscopeMessage).CreateRequest()));

            var response = await base.SendAsync(request, cancellationToken);

            if (_filter == null || _filter(request, response))
            {
                
                var runscopeMessage2 = new RunscopeMessage()
                {
//                UniqueIdentifier = messageId,
                    Request = runscopeRequest,
                    Response = new RunscopeResponse(response)
                };

                var messagesLink = new MessagesLink();
                HandleFailedMessageLog(
                    _RunscopeClient.SendAsync(messagesLink.Update(_bucketKey, runscopeMessage2).CreateRequest()));
            }
            return response;
        }
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request,
                                                                      CancellationToken cancellationToken)
        {
//            var messageId = Guid.NewGuid();
            var runscopeRequest = new RunscopeRequest(request);  // Preread to ensure non-rewindable stream is not consumed by app

            //var runscopeMessage = new RunscopeMessage()
            //{
            //    UniqueIdentifier = messageId,
            //    Request = runscopeRequest
            //};

//            HandleFailedMessageLog(_RunscopeClient.SendAsync(messagesLink.Update(_bucketKey, runscopeMessage).CreateRequest()));

            var response = await base.SendAsync(request, cancellationToken);

            if (_filter == null || _filter(request, response))
            {
                var runscopeMessage2 = new RunscopeMessage()
                {
//                UniqueIdentifier = messageId,
                    Request  = runscopeRequest,
                    Response = new RunscopeResponse(response)
                };

                var messagesLink = new MessagesLink();
                HandleFailedMessageLog(
                    _RunscopeClient.SendAsync(messagesLink.Update(_bucketKey, runscopeMessage2).CreateRequest()));
            }
            return(response);
        }
Exemple #3
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request,
                                                                      CancellationToken cancellationToken)
        {
            var runscopeRequest = new RunscopeRequest(request);  // Preread to ensure non-rewindable stream is not consumed by app

            var response = await base.SendAsync(request, cancellationToken);

            string bucket = _bucketKey;

            if (_bucketFilter != null)
            {
                bucket = _bucketFilter(request, response);
            }

            if (string.IsNullOrWhiteSpace(bucket))
            {
                return(response);
            }

            if (_filter == null || _filter(request, response))
            {
                var runscopeMessage = new RunscopeMessage()
                {
                    Request  = runscopeRequest,
                    Response = new RunscopeResponse(response)
                };

                var messagesLink = new MessagesLink();
                HandleFailedMessageLog(
                    _RunscopeClient.SendAsync(messagesLink.Update(bucket, runscopeMessage).CreateRequest()));
            }
            return(response);
        }