mirror of
https://github.com/appium/appium.git
synced 2026-05-04 09:20:30 -05:00
Don't set Content-Length header for http POSTs with empty body.
This commit is contained in:
@@ -4,19 +4,13 @@ var express = require('express')
|
||||
, _s = require('underscore.string');
|
||||
|
||||
module.exports.parserWrap = function(req, res, next) {
|
||||
// wd.js sends us http POSTs with empty body which will make bodyParser fail.
|
||||
var cLen = req.get('content-length');
|
||||
if (typeof cLen === "undefined" || parseInt(cLen, 10) <= 0) {
|
||||
req.headers['content-length'] = 0;
|
||||
next();
|
||||
} else {
|
||||
// allow guineapig
|
||||
if (!_s.startsWith(req.path, "/test")) {
|
||||
// hack because python client library sux
|
||||
if (req.headers['content-type'] === 'application/x-www-form-urlencoded') {
|
||||
req.headers['content-type'] = 'application/json';
|
||||
}
|
||||
// allow guineapig
|
||||
if (!_s.startsWith(req.path, "/test")) {
|
||||
// hack because python client library sux
|
||||
if (req.headers['content-type'] === 'application/x-www-form-urlencoded') {
|
||||
req.headers['content-type'] = 'application/json';
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user