I have created a web site (c# on Azure) which provides responses to a microcontroller (using a Texas Instruments CC3100 wifi chip).
The microcontroller has limited memory, and I would like to limit its buffer size to under 1000 bytes. I can use Transfer encoding Chunked (and it works), but I am struggling to work out how to set a maximum chunk size as it appears to be set "under the TCP/IP hood".
My current abbreviated code is as follows: -
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;
}
}
So far as I can see, there are no server or header settings which will limit chunk size. Is there some way of forcing a small chunk size (some kind of write followed by a flush maybe?).
Any help much appreciated.