我有一个带有POST方法的Web API控制器,如下所示。
public class MyController : ApiController
{
// POST: api/Scoring
public HttpResponseMessage Post([FromBody]ReallyLargeJSONObject request)
{
// some processing of this large json object
return Request.CreateResponse(HttpStatusCode.OK, someResponseObject);
}
....
}
这由HTTPClient使用,如下所示
HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.BaseAddress = new Uri("http://localhost");
ReallyLargeJSONObject request = new ReallyLargeJSONObject();
var task = httpClient.PostAsJsonAsync("api/my", request)
我已经在几个地方读过,在.NET 4.5中,HttpClient类会对数据进行流式传输(并且不会对其进行缓冲)。这很好,因为我的服务器不会因大包而过载。但是我想测试一下。为此,我将客户端的ReallyLargeJSONObject实例的大小设置为~20MB。我也尝试使用大包(~1GB)。当我使用fiddler时,它只显示一个请求到服务器。我的问题: