Skip to content
This repository

Corrected: a 0 length body is a "null" body #768

Closed
wants to merge 1 commit into from

1 participant

perki
perki
perki commented March 27, 2013

Safari may send a content-length: 0 which causes utils.hasBody to return true

More detail on my comment on :
#415 (comment)

perki Corrected: a 0 length body is a "null" body
Safari may send a content-length: 0 which causes `utils.hasBody` to return true

senchalabs#415 (comment)
52630f4
perki perki closed this March 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 27, 2013
perki Corrected: a 0 length body is a "null" body
Safari may send a content-length: 0 which causes `utils.hasBody` to return true

senchalabs#415 (comment)
52630f4
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 2 additions and 2 deletions. Show diff stats Hide diff stats

  1. 4  lib/middleware/json.js
4  lib/middleware/json.js
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 /*!
3 2
  * Connect - json
4 3
  * Copyright(c) 2010 Sencha Inc.
@@ -68,7 +67,8 @@ exports = module.exports = function(options){
68 67
         var first = buf.trim()[0];
69 68
 
70 69
         if (0 == buf.length) {
71  
-          return next(utils.error(400, 'invalid json, empty body'));
  70
+          req.body = null;
  71
+          return next();
72 72
         }
73 73
         
74 74
         if (strict && '{' != first && '[' != first) return next(utils.error(400, 'invalid json'));
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.