1

I have a relatively large (50K) text file being POSTed:

curl -H "Content-Type:text/plain"  -d @system.log http://localhost:8888/

Testing using a proxy, I can see the full contents of the file are being posted.

However Express.JS sees 100:Continue in the headers, and a blank body. I have :

app.use(express.bodyParser());

enabled, BTW. Here are the headers:

{ 'user-agent': 'curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5',
  host: 'localhost:8888',
  accept: '*/*',
  'content-type': 'text/plain',
  'content-length': '55909',
  expect: '100-continue' }

req.body is empty:

{}

How can I see all the data being posted in Express.JS?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494

1 Answers1

1

My guess is that node is automatically sending the 100-continue response as per the node http module docs (assuming you are using a new enough node version). What I guess is happening is just simply that the text/plain content type is not a format that bodyParser can parse into something else (as opposed to json or www-form-urlencoded). So you can get your data from the standard data event which the request will emit for each chunk of data it reads.

Peter Lyons
  • 142,938
  • 30
  • 279
  • 274
  • that's correct. Using the data event sounds reasonable, I've also posted another question at http://stackoverflow.com/questions/12497358/handling-text-plain-in-express-3 re: handling the Contect-Type in Express (via Connect)? – mikemaccana Sep 19 '12 at 15:00