POST large data buffers from a Wio Terminal

I’ve been trying to post images to an HTTP end point from my Wio Terminal. I have a buffer of about 9KB in size. When I post this, it doesn’t post all the data, and I get an error on my server code showing an unexpected end of request content.

I’ve tried buffers at a few different sizes:

1KB - sends fine
2KB - sends fine
4KB - unexpected end of request content

It looks like somewhere in the firmware there is a limit on how many bytes get sent. I get the same on WifiClient and WifiClientSecure.

This is my code:

HTTPClient httpClient;
httpClient.begin(client, ENDPOINT);
httpClient.addHeader("Content-Type", "application/octet-stream");

length = 1024;

byte buff[length];
int httpResponseCode = httpClient.POST(buff, length);

If length is 1 or 2KB, then I get a 200 back. If it is 4KB or above, I get -3 back (HTTPC_ERROR_SEND_PAYLOAD_FAILED). Digging into the code, and the error is kErpcStatus_BufferOverrun.

Any ideas? I’m trying to send an image to a cloud AI service, so need to make a single call with the data.

Update - I was able to get it working by using the WiFi client directly, and writing the binary data in chunks of 1024 bytes.

I’ve created an issue for this on the rpcWiFi GItHub repo, as well as created a PR to apply a change in the HTTPClient to chunk the writes into 1024 byte blocks.

I’m not sure but can it be that changing to a larger value

#define HTTP_TCP_BUFFER_SIZE (1460)

in HTTPClient.h

would solve the problem

That’s only used when using streams - I’ve got a byte array that I’m trying to post, and there I can’t find a built in way to convert that to a stream.

Though the sendRequest method that uses a stream does what I need to send the data in chunks, I just don’t have a stream :frowning: