public virtual object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            HttpRequestMessageProperty prop = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
            string body = General.ReadMessageBody(ref request);

            logger(General.GetHttpRequestLog(prop.Method, request.Headers.To.AbsoluteUri, prop.Headers, body));

            return(request);
        }
 private static void LogRequest(
     string method,
     string requestUri,
     HttpRequestHeaders headers,
     string body,
     Action <string> logger)
 {
     if (logger != null)
     {
         logger(General.GetHttpRequestLog(method, requestUri, headers, body));
     }
 }
        protected override HttpRequestMessage ProcessRequest(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            string body = String.Empty;

            if (request.Content != null)
            {
                var contentHeaders = request.Content.Headers;
                var stream         = new MemoryStream();
                request.Content.CopyToAsync(stream).Wait();
                if (stream.Length > 0)
                {
                    stream.Position = 0;
                    body            = XElement.Load(stream).ToString();
                }
                stream.Position = 0;
                request.Content = new StreamContent(stream);
                contentHeaders.ForEach(kv => request.Content.Headers.Add(kv.Key, kv.Value));
            }
            logger(General.GetHttpRequestLog(request.Method.ToString(), request.RequestUri.AbsoluteUri, request.Headers, body));

            return(request);
        }