pandastrike / shred

A Node.js HTTP Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wrong content-length with accentuated characters

kapouer opened this issue · comments

Hi,
this will eat the last char of the stringified request body :

shred.put({
    url: someurl,
    content: {
        test: "testé"
    },
    headers: {
        accept: "application/json",
        content_type: "application/json"
    }
});

Because (new Buffer('testé')).length == 6 and 'testé'.length == 5
A crude fix is replacing in content.js

get: function() { return this.body.length; }

by

get: function() { return new Buffer(this.body).length; }

Regards.