我创建了一个网站(Azure 上的 c#),它提供对微控制器的响应(使用德州仪器 CC3100 wifi 芯片)。
微控制器的内存有限,我想将其缓冲区大小限制在 1000 字节以下。我可以使用传输编码块(并且它有效),但我正在努力解决如何设置最大块大小,因为它似乎设置为“在 TCP/IP 引擎盖下”。
我目前的缩写代码如下: -
public class HITController : ApiController
{
public async Task<HttpResponseMessage> Post()
{
byte[] RetContent = null;
byte[] bytes = await Request.Content.ReadAsByteArrayAsync();//do stuff with incoming bytes
RetContent = responseSelect(SiteSN, inData);//this gets a byte array of content to return
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.StatusCode = HttpStatusCode.OK;
ByteArrayContent ResponseContent = new ByteArrayContent(RetContent);
result.Content = ResponseContent;
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
result.Headers.TransferEncodingChunked = true;
return result;
}
}
据我所知,没有服务器或标头设置会限制块大小。是否有某种方法可以强制使用小块大小(可能是某种写入,然后是刷新?)。
非常感谢任何帮助。