xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Beacon API maximum data size limit All In One

Beacon API maximum data size limit All In One

// sendBeacon limit for Chrome v40 on Windows (2^16)
function test(n = 65536) {
    const url = 'http://jsfiddle.net?sendbeacon';
    // generate string of length n
    // http://stackoverflow.com/questions/14343844/create-a-string-of-variable-length-filled-with-a-repeated-character
    // const data = new Array(n+1).join('X');
    const data = `X`.repeat(n);
    const result = navigator.sendBeacon(url, data);
    // false
    if(!result) {
        flag = false;
        window.localStorage.setItem('beacon-api-max-size', n);
        alert(`data limit reached ${n}`);
    } else {
        // ignore
    }
    return result;
}

let flag = true;
let n = 65536;
// 2^16 / Math.pow(2, 10); / 2**16
while (flag) {
    test(n);
    n += 2**10;
}


// sendBeacon limit for Chrome v40 on Windows (2^16)
function test(n = 65536) {
    const url = 'https://cdn.xgqfrms.xyz/?sendbeacon';
    // generate string of length n
    // http://stackoverflow.com/questions/14343844/create-a-string-of-variable-length-filled-with-a-repeated-character
    // const data = new Array(n+1).join('X');
    const data = `X`.repeat(n);
    const result = navigator.sendBeacon(url, data);
    // false
    if(!result) {
        flag = false;
        window.localStorage.setItem('beacon-api-max-size', n);
        alert(`data limit reached ${n}`);
    } else {
        // ignore
    }
    return result;
}

let flag = true;
let n = 1;
// let n = 65536;
// 2^16 / Math.pow(2, 10); / 2**16
while (flag) {
    test(n);
    n += 2**10;
}
// 12289 ❌

// sendBeacon limit for Chrome v40 on Windows (2^16)
function test(n = 65536) {
    const url = 'https://cdn.xgqfrms.xyz/?sendbeacon';
    // generate string of length n
    // http://stackoverflow.com/questions/14343844/create-a-string-of-variable-length-filled-with-a-repeated-character
    // const data = new Array(n+1).join('X');
    const data = `X`.repeat(n);
    const result = navigator.sendBeacon(url, data);
    // false
    if(!result) {
        flag = false;
        window.localStorage.setItem('beacon-api-max-size', n);
        alert(`data limit reached ${n}`);
    } else {
        // ignore
    }
    return result;
}

let flag = true;
let n = 100000000000;
// let n = 65536;
// 2^16 / Math.pow(2, 10); / 2**16
while (flag) {
    test(n);
    n += 2**10;
}
VM347:7 Uncaught RangeError: Invalid string length
    at String.repeat (<anonymous>)

https://cdn.xgqfrms.xyz/?sendbeacon



// sendBeacon limit for Chrome v40 on Windows (2^16)
function test(n = 65536) {
    const url = 'https://cdn.xgqfrms.xyz/?sendbeacon';
    // generate string of length n
    // http://stackoverflow.com/questions/14343844/create-a-string-of-variable-length-filled-with-a-repeated-character
    // const data = new Array(n+1).join('X');
    const data = `X`.repeat(n);
    const result = navigator.sendBeacon(url, data);
    // false
    if(!result) {
        flag = false;
        window.localStorage.setItem('beacon-api-max-size', n);
        alert(`data limit reached ${n}`);
    } else {
        // ignore
    }
    return result;
}

let flag = true;
let n = 100000000;
// let n = 65536;
// 2^16 / Math.pow(2, 10); / 2**16
while (flag) {
    test(n);
    n += 2**10;
}
100001024

refs

https://stackoverflow.com/questions/28989640/navigator-sendbeacon-data-size-limits



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-04-07 20:17  xgqfrms  阅读(137)  评论(5编辑  收藏  举报