Skip to content

Commit

Permalink
add Content-Length for multipart request, but 11/73 tests failing ins…
Browse files Browse the repository at this point in the history
…tead of 8/73
  • Loading branch information
Duana Stanley committed Feb 24, 2012
1 parent 647a791 commit a5ea0ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/multipartform.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ var exportMethods = {
for (var name in parts) totalSize += new Part(name, parts[name], boundary).sizeOf();
return totalSize + boundary.length + 6;
},
size: function(data, boundary) {
var totalSize = 0;
boundary = boundary || exports.defaultBoundary;
for (var name in data)
totalSize += new Part(name, data[name], boundary).sizeOf();
return totalSize + boundary.length + 6;
},
write: function(stream, data, callback, boundary) {
var r = new MultiPartRequest(data, boundary);
r.write(stream, callback);
Expand Down
1 change: 1 addition & 0 deletions lib/restler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function Request(uri, options) {

if (this.options.multipart) {
this.headers['Content-Type'] = 'multipart/form-data; boundary=' + multipart.defaultBoundary;
this.headers['Content-Length'] = multipart.size(this.options.data, multipart.defaultBoundary);
} else {
if (typeof this.options.data == 'object') {
this.options.data = qs.stringify(this.options.data);
Expand Down

0 comments on commit a5ea0ff

Please sign in to comment.