Is there a way to increase the allowed size of post requests?

Sounds great! I’ll take a look at it properly later and try to figure out what you’re doing :wink:

How long does this take to encode and decode 64 kiB?

I think you’ve made an error in the design of the encoding leading to this large encoded size. Code points above 127 take 2 (or more) bytes to encode in UTF-8. 0-127 take one byte, and 128-2247 take two bytes, so the expected byte length of 65536 uniformly distributed bytes would be 65536 * (0.5 * 1 + 0.5 * 2) = 98304. Your experiment resulted in about that size.

The reason it took so much is because it is rendered as unsafe JSON characters. Which means using JSON to stringify the string will add escape characters, which is why the size increases. The encoding works, but it makes it larger. Encoding (not to be confused with compression) means to turn some given input to some other output.

The encode/decode is based on JSON so it shouldn’t take long, however the generation of the image expectantly takes longer. However, you don’t actually need to encode the image, it can be sent as ASCII characters in the request body without any encoding.

The raw image uses 524.288 bits, nothing more, nothing less. In bytes that is 65.536 bytes, which is the amount of pixels there are in a 256px squared image. Each pixel is a random number from 0-255, so one byte per pixel.

Good point. I hadn’t taken that into account in the above estimate.

I meant “large encoded size” compared to using base64. Didn’t mean to imply that encoding it would make it smaller than the original input.

I’m curious about the BigInt manipulation.

What is it that you’re curious about? I’ll try to explain my best! :smiley:

How long does this take to encode and decode 64 kiB?

If you give me a moment I’ll write a benchmark for it :wink:

I heard of something called multipart, which I use for pomagranate video uploads, i’m not sure if it can help with this
in fact it could be the opposite of what you want to do. Try sending multiple requests to the server, each with a chunk of data

There are the results ^^

Encoding 64 kb takes on average 479 nano seconds.

Decoding ASCII back to bigint takes on averge 377 nano seconds.

5 Likes

Thats pretty good.

@javaarchive yep, probably is the oppposite to what I want! I could send it in chunks… but then I’ll be storing it in a database at some point anyway, so that will make no difference :smile: