Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bodyParser IE9 support #801

Closed
donniev opened this issue May 15, 2015 · 6 comments
Closed

bodyParser IE9 support #801

donniev opened this issue May 15, 2015 · 6 comments
Labels

Comments

@donniev
Copy link

donniev commented May 15, 2015

IE 9 requests do not set the content-type and the body-parser leaves req.body as undefined. In version 2.60 that was not true. I am not sure when behavior changed but as of 2.85 it definitely has and still leaves it undefined in 3

@yunong
Copy link
Member

yunong commented May 22, 2015

Can you give me an example request?

@micahr micahr added the plugins label Jun 29, 2015
@micahr micahr added this to the Release: 3.1.x milestone Jun 29, 2015
@micahr
Copy link
Member

micahr commented Jun 29, 2015

Looks like there is no default body parser when a content-type isn't sent by the client. We should useapplication/x-www-form-urlencoded as the default to catch these type of cases.

@micahr micahr modified the milestones: Release: 4.0.x, Release: 3.1.x Jun 29, 2015
@ediogodias
Copy link

Any one found a workaround for this? Im tryng to make CORS requests form ie9 and i cant parse the body of the post request. thanks

@donniev
Copy link
Author

donniev commented Aug 19, 2015

This is in 4.0 milestone but does not seem to have been assigned or addressed in 4.0. Do we have an estimate of when this will be addressed?

@ediogodias
Copy link

a workaround for anyone interested until this doesn't get fixed into native plugin

function ieParser(req, res, next) {
  if (req.method === 'GET' || req.method === 'HEAD') {
    next();
    return;
  }
  if(req.body == undefined) {
    var buffer = []

    req.on('data', function onRequestData(chunk) {
      buffer.push(chunk)
    });

    req.once('end', function() {
      var concated = Buffer.concat(buffer);
      req.body = JSON.parse(concated.toString('utf8'));
      next()
    });
  } else {
    next();
    return;
  }
}

module.exports = ieParser;

And use this as a middleware of your app, after processing the restify.bodyParser().
I am forcing JSON encoding, so change to your needs;

@micahr
Copy link
Member

micahr commented Aug 19, 2015

@donniev I don't have an exact timeline for when this will be addressed. It is obviously affecting several people, so we will do our best to get it fixed as soon as possible.

@retrohacker retrohacker changed the title IE9 post fails to parse body bodyParser IE9 support Apr 29, 2017
@retrohacker retrohacker modified the milestone: Release: 4.0.x Apr 29, 2017
retrohacker pushed a commit that referenced this issue Apr 29, 2017
Closes:

#289
#381
#474
#575
#790
#633
#717
#576
#576
#909
#875
#860
#853
#850
#829
#813
#801
#921
#1101
#1019
#989
#632
#708
#737
#859
#1326
#1327
#927
#1099
#1068
#1040
#1035
#957
#948
#1134
#1136
#1183
#1206
#1286
#1323

> Note: this issue closes _but does not resolve_ the issues listed, we are just tracking them in another medium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants