Question

My application uses express and it is hosted on nodejitsu.com. Only first 400-1500 characters of POST request are received. Locally, this does not happen. Chrome dev kit shows that the request was sent fine. Here is how I receive the request:

function settings_post(request, response) {
console.log('getting a '+request.method);
if (request.method == 'POST') {
    var body = '';
    request.on('data', function (data) {
        body += data;   //needs to be converted to a string manually, for some reason
        console.log('received POST: '+body);
    });
    request.on('end', function () {
        var obj = qs.parse(body);

        //update settings variable 
        var str = obj.dictionary;
        delete obj.dictionary;
        var array = str.replace(/[\r\n]+$/g, '').split('\r\n');
        console.log('parced array: '+array);    //this doesn't happen

Logs show:

[07/04 15:38:09 GMT] POST / [07/04 15:38:09 GMT] recieved POST: tabname=TEST_LEVEL1&dictionary=test%2C+long%0D%0Aand%2C+et%0D%0Aif%2C+si%0D%0Agood%2C+bon%0D%0Ahere%2C+ici%0D%0Ano%2C+non%0D %0Ayes%2C+oui%0D%0Anice+%28weather%29%2C+beau%0D%0Aexpensive%2C+cher%0D%0Adad%2C+papa%0D%0Ato+read%2C+lire%0D%0Astrong%2C+good+at+%28subject%29%2C+fort%0D%0AFAL SE%2C+faux%0D%0Ahigh%2C+haut%0D%0Along%2C+long%0D%0Aalone%2C+seul%0D%0Aall%2C+tout%0D%0ATRUE%2C+vrai%0D%0Apretty%2C+joli%0D%0Augly%2C+laid%0D%0Aquick%2C+vite%0D %0Afat%2C+gros%0D%0Atoo%2C+trop%0D%0Aquickly%2C+vite%0D%0Ablue%2C+bleu%0D%0Abrown%2C+brun%0D%0Agrey%2C+gris%0D%0Ablack%2C+noir%0D%0Apink%2C+rose%0D%0Agreen%2C+v ert%0D%0Aso%2C+donc%0D%0Abut%2C+mais%0D%0Athen%2C+puis%0D%0AJune%2C+juin%0D%0AMarch%2C+mars%0D%0Awith%2C+avec%0D%0Ain%2C+dans%0D%0Afor%2C+in+order%2C+pour%0D%0A at+%28someone%E2%80%99s+house%29%2C+chez%0D%0Awithout%2C+sans%0D%0Aexcept%2C+sauf%0D%0Aunder%2C+sous%0D%0Atowards%2C+vers%0D%0Ahalf%2C+demi%0D%0AWhat%3F%2C+que% 3F%0D%0AWho%3F%2C+qui%3F%0D%0Ayesterday%2C+hier%0D%0Ato+say%2C+dire%0D%0Ato+see%2C+voir%0D%0Ato+laugh%2C+rire%0D%0Ato+hire%2C+to+rent%2C+louer%0D%0Afree%2C+avai lable%2C+vacant%2C+libre%0D%0Ato+put+someone+up%2C+to+accommodate%2C+loger%0D%0Ato+go%2C+aller%0D%0Acold%2C+froid%0D%0Ato+pay%2C+payer%0D%0Afresh%2C+frais%0D%0A the+water%2C+l%27eau%0D%0Ato+fit%2C+to+suit%2C+aller%0D%0Abig%2C+grand%0D%0Awide%2C+large%0D%0Ato+like%2C+aimer%0D%0Amum%2C+maman%0D%0Anice%2C+likeable%2C+sympa %0D%0Aold+%28masculine%29%2C+vieux%0D%0Ayoung+pe [07/04 15:38:09 GMT] getting a POST

The limit seems arbitrary and this doesn't happen locally. Any ideas?

Was it helpful?

Solution

The problem was that I redirected right after I received a POST request, that's why I saw only the first chunk of POST. Moving redirect to the "end" event fixed the problem.

Since my code worked if there was only a single chunk of POST, it worked on short POSTs as well as locally. This was not express's or host's problem, just my buggy code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top