Skip to content

Instantly share code, notes, and snippets.

@cdm
Created June 6, 2017 09:23
Show Gist options
  • Save cdm/711708411aa56de9ad780c0f9e31f137 to your computer and use it in GitHub Desktop.
Save cdm/711708411aa56de9ad780c0f9e31f137 to your computer and use it in GitHub Desktop.
Echo request/response in HttpMessageHandler
#if DEBUG
Debug.WriteLine("Request:");
Debug.WriteLine(request.ToString());
if (request.Content != null)
{
var bytes = await request.Content.ReadAsByteArrayAsync();
Debug.WriteLine(bytes.Length);
Debug.WriteLine(Encoding.UTF8.GetString(bytes, 0, bytes.Length));
Debug.WriteLine(await request.Content.ReadAsStringAsync());
}
Debug.WriteLine("");
#endif
// Send the request, with auth headers if available
var r = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
#if DEBUG
Debug.WriteLine("Response:");
Debug.WriteLine(r.ToString());
if (r.Content != null)
{
Debug.WriteLine(await r.Content.ReadAsStringAsync());
}
Debug.WriteLine("");
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment