Created
March 31, 2014 14:39
-
-
Save darrelmiller/9893857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NullJsonHandler : DelegatingHandler | |
{ | |
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
var response = await base.SendAsync(request, cancellationToken); | |
if (response.Content == null) | |
{ | |
response.Content = new StringContent("{}"); | |
} else if (response.Content is ObjectContent) | |
{ | |
var objectContent = (ObjectContent) response.Content; | |
if (objectContent.Value == null) | |
{ | |
response.Content = new StringContent("{}"); | |
} | |
} | |
return response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment