Hey All,
I have a really strange issue that I can't seem to track down. I am posting small JSON objects to a webservice and getting back large JSON objects represented as strings. The problem I'm having is that randomly in the JSON object that is returned I get the following text:
DNT: 1 Connection: close
This obviously throws up when I try to deserialize the JSON. At first it was the Expect100-Continue in the body of the message, then it was the KeepAlive stuff and now it's the Connection: Close stuff. I am just using standard WebClient however I created a new class that inherits from WebClient so I can set the headers properly, here it is:
public class CustomWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address);
if (request is HttpWebRequest)
{
(request as HttpWebRequest).KeepAlive = false;
(request as HttpWebRequest).ServicePoint.Expect100Continue = false;
}
return request;
}
}
and here is my implementation for the call:
using (var webClient = new CustomWebClient())
{
webClient.Proxy = null;
webClient.Headers[HttpRequestHeader.ContentType] = Constants.HttpJSONencodedHeader;
return webClient.UploadData(request.Url, Constants.HttpPostVerb, Encoding.ASCII.GetBytes(request.Params.GetFormattedJSon()));
}
What I am expecting back is a JSON object that looks like this:
(simplified)
"276425": {
"min": 1.0,
"max": 1.0,
"count": 1,
"missing": 0,
"distinctValues": [1],
"countDistinct": 1,
"sum": 1.0,
"sumOfSquares": 1.0,
"mean": 1.0,
"stddev": 0.0,
"facets": {}
}
This is what randomly comes back every now and then:
"280950": {
"min": 1.0,
"max": 1.0,
"count": 1,
"missing": 0,
"distinctValues": [1],
"countDistinct": 1,
"sum": 1.
DNT: 1
Connection: close "stddev": 0.0,
"facets": {}
}
the part to highlight is i have this right in the middle of the json object:
.
DNT: 1
Connection: close
Any and all help/suggestions would be greatly appreciated.