Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[ISSUE #26] report correct content-length of utf-8 and other unicode …

…strings
  • Loading branch information...
commit f8bc7d98801876c5b3c2b04e322f560cefe02d81 1 parent cfe5b5e
@coolaj86 authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/options.js
View
7 lib/options.js
@@ -346,6 +346,13 @@
if (options.headers["content-type"].match(/application\/json/) ||
options.headers["content-type"].match(/text\/javascript/)) {
options.encodedBody = JSON.stringify(options.body);
+ try {
+ // so that node can know the true length of json strings
+ options.encodedBody = new Buffer(options.encodedBody);
+ } catch(e) {
+ // this must be a browser
+ // it will know the true length of a string without me telling it.
+ }
} else if (options.headers["content-type"].match(/application\/x-www-form-urlencoded/)) {
options.encodedBody = uriEncodeObject(options.body);
}

0 comments on commit f8bc7d9

Please sign in to comment.
Something went wrong with that request. Please try again.