Skip to content

Instantly share code, notes, and snippets.

@huzemin
Created January 23, 2016 06:00
Show Gist options
  • Save huzemin/0cb1347c9472a7a85680 to your computer and use it in GitHub Desktop.
Save huzemin/0cb1347c9472a7a85680 to your computer and use it in GitHub Desktop.
获取HTTP POST表单提交数据的Boundary
function getBoundary(req) {
if (req && req.headers) {
var content_type = req.headers['content-type'].split(';');
if (content_type.length > 1) {
var raw_boundary = content_type.pop().split('=');
var boundary = raw_boundary[1];
return boundary;
}
}
else {
throw new Error("参数错误: 参数必须为有效的Http.request");
}
}
module.exports = getBoundary;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment