Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I read large amounts of CGI data via POST in Rebol3?

I'm trying to upload an image using POST. Then on the server to get the POST data, I use:

data: read system/ports/input

...but it seems that the data is truncated.

There doesn't seem to be some specific boundary where the data are truncated. I'm uploading images in range from cca 15-200kB, and the resulting data are few hundreds to few tens of kB long, so there's no artificial boundary like 32'000 bytes.

Does anyone have experience with getting data from POST?

like image 937
Dan Lee Avatar asked Nov 26 '25 03:11

Dan Lee


2 Answers

The read action on system/ports/input works at a low level, like a stream. Continuous reads will return partial data until the end of input is reached. The problem is that system/ports/input will return an error at the end of input instead of none! or an empty string.

The following code works for me to read large POST input:

image: make binary! 200'000
while [
    not error? try [data: read system/ports/input]
][
        append image data
]
like image 100
Dan Lee Avatar answered Nov 28 '25 02:11

Dan Lee


with r3-64-view-2014-02-14-1926d8.exe I used

while [
    all [
       not error? try [data: read system/ports/input]
       0 < probe length? data
    ]
][
    append image data
]
print length? image

And did

D:\own\Rebol>r3-64-view-2014-02-14-1926d8.exe read-img.r < r3-64-view-2014-02-14-1926d8.exe > err.txt

and got

.
.
16384
16384
16384
2048
0
1181696
like image 40
sqlab Avatar answered Nov 28 '25 03:11

sqlab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!