env-js icon indicating copy to clipboard operation
env-js copied to clipboard

Content-Length needs to be specdified for spydermonkey port

Open julkiewicz opened this issue 14 years ago • 0 comments

The default implementation doesn't work appropriately for POST/PUT requests. The server receives an empty message body. There needs to be added 'Content-Length' parameter to the header of the request. I changed the code in envjs/platform/spydermonkey.js as follows:

if(data && (xhr.method == "PUT" || xhr.method == "POST" )) {
    if(data instanceof Document){
        data = (new XMLSerializer()).serializeToString(data);
    } else {
        data = data + ''
    }
    if(data.length&&data.length>0){
        connection.putheader('Content-Length', data.length);
        connection.endheaders(data);
    }else{
        connection.endheaders();
    }
}else{
    connection.endheaders();
}

julkiewicz avatar Jun 11 '11 01:06 julkiewicz