[413] Request Entity Too Large #618

Closed
paulyoung opened this Issue Aug 7, 2013 · 3 comments

Comments

Projects
None yet
3 participants

I get a 413 response if I do this using request.

req = request.post 'http://myurl.com/', (error, response, body) ->
  console.log body

form = req.form()
file = fs.createReadStream('file.json')
form.append 'file', file

However, if I do the following using the form-data library directly I get a 200 but the connection doesn't seem to close properly.

form = new FormData()
form.append 'file', fs.createReadStream('file.json')

form.submit 'http://myurl.com/', (err, res) ->
  console.log res.statusCode

Am I doing something wrong when using request?

Currently I'm running into a similar issue.

As first a short piece of code which worked until version 2.36 like a charm:

var Fs = require('fs'),
  Request = require('request');

var r = Request.post({
    url: 'http://my.domain/upload'
  },
  function (err, httpResponse, body) {
    console.log(err, httpResponse, body);
  });

var file = '/private/tmp/test.file';

// form data
var form = r.form();
form.append('fData', Fs.createReadStream(file), {knownLength: 23765234}));
r.setHeader('Content-Length', form.getLengthSync());

Since upgrading to 2.40 all requests to the same earlier working nginx servers are failing with and 413 error code.
From the changelog I'm usable to find a possibly reason. Even at the form-data changes nothing seems to directly affect this kind of problem.

With v2.40 (and maybe the a meanwhile modified part of form-data) the object with knownlength as property is no longer needed, likewise getLengthSync() seems to be done internally automatically.
In my case the old code is running again, only the mentioned lines have to be modified and/or removed.

var Fs = require('fs'),
  Request = require('request');

var r = Request.post({
    url: 'http://my.domain/upload'
  },
  function (err, httpResponse, body) {
    console.log(err, httpResponse, body);
  });

var file = '/private/tmp/test.file';

// form data
var form = r.form();
form.append('fData', Fs.createReadStream(file));
Owner

mikeal commented Aug 28, 2014

Is this still an issue?

This is so old I'm closing, if it is actually still an issue just let me know and I'll re-open.

@mikeal mikeal closed this Aug 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment