Created
January 23, 2016 06:00
-
-
Save huzemin/0cb1347c9472a7a85680 to your computer and use it in GitHub Desktop.
获取HTTP POST表单提交数据的Boundary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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