This script creates a String of length "len" and then returns the string length:
$ cat str.js
session.input.readAsJSON(function (error, len) { throwIf(error);
var str = new Array(len + 1).join( '#' );
session.output.write(str.length);
});
function throwIf(error) { if (error) throw error; }
$
This script creates a Buffer of length "len" and then returns the Buffer length:
$ cat buf.js
session.input.readAsJSON(function (error, len) { throwIf(error);
var buf = new Buffer(len);
session.output.write(buf.length);
});
function throwIf(error) { if (error) throw error; }
$
The maximal values get processed quickly and length is returned:
$ time ( coproc2 str.js <(echo $((1024*1024*1024-25)) ) dp3-l3.boeblingen.de.ibm.com:2227 )
1073741799
real 0m0.630s
user 0m0.002s
sys 0m0.010s
$
$ time ( coproc2 buf.js <(echo $((2*1024*1024*1024-1)) ) dp3-l3.boeblingen.de.ibm.com:2227 )
2147483647
real 0m0.656s
user 0m0.002s
sys 0m0.029s
$
1GB-24bytes String or 2GB Buffer error out:
[stammw@dp0-l3 ~]$ time ( coproc2 str.js <(echo $((1024*1024*1024-24)) ) dp3-l3.boeblingen.de.ibm.com:2227 )
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>Internal Error (from client)</faultstring></env:Fault></env:Body></env:Envelope>
real 0m0.019s
user 0m0.001s
sys 0m0.012s
[stammw@dp0-l3 ~]$ time ( coproc2 buf.js <(echo $((2*1024*1024*1024)) ) dp3-l3.boeblingen.de.ibm.com:2227 )
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>Internal Error (from client)</faultstring></env:Fault></env:Body></env:Envelope>
real 0m0.017s
user 0m0.005s
sys 0m0.007s
[stammw@dp0-l3 ~]$
------------------------------
Hermann Stamm-Wilbrandt
Compiler Level 3 support & Fixpack team lead
IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
------------------------------