ethanchewy / PythonBuddy

1st Online Python Editor With Live Syntax Checking and Execution
https://pythonbuddy.com
BSD 3-Clause "New" or "Revised" License
277 stars 84 forks source link

HTTP 414 Request-URI Too Large #25

Closed Chessax closed 6 years ago

Chessax commented 6 years ago

If the code is longer than the server specified allowed request limit (seemingly 8KB) a HTTP 414 error is returned. This is because HTTP GET is used, and can easily be fixed by using HTTP POST.

E.g. replacing in javascript.js: https://github.com/ethanchewy/PythonBuddy/blob/895ecbcbbe4e7053913af4b60365cf1c3c31f7b1/static/js/javascript.js#L88-L95

With this:

$.post('/check_code', {
    text :  code
}, function(data) {
    current_text = data;
    //Check Text
    check(current_text);
    return false;
}, 'json');

If this limit is intentional, then there are still better ways to handle it than just "crashing". E.g. just checking the length of the string to be sent to the server beforehand, and telling the user that is the case.

Chessax commented 6 years ago

@ethanchewy While it's nice to see this "fixed" so quickly, you didn't actually solve anything. Adding 'json' as an argument does nothing, since the function only accepts three arguments: jQuery.getJSON( url [, data ] [, success ] ). You have to change the jQuery function to $.post as well (which accepts an additional dataType argument: jQuery.post( url [, data ] [, success ] [, dataType ])

Unfortunately I'm not very proficient at using git or I'd submit a pull request (or whatever it is called).

ethanchewy commented 6 years ago

Thank you! Just fixed it over here: https://github.com/ethanchewy/PythonBuddy/commit/a11cb93f0f55246416d26b3a81a717a34e45e24e