Skip to content

Commit

Permalink
fix(bins): create bin with simplest HAR objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Feb 12, 2016
1 parent 534511f commit 6a85fc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lib/routes/bins/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = function (req, res, next) {
mock = req.jsonBody.response
}

// overritten by application/x-www-form-urlencoded or multipart/form-data\
// exception for the web Form
// TODO eliminate this and rely on req.simple.postData.text
if (req.simple.postData.params && req.simple.postData.params.response) {
try {
mock = JSON.parse(req.simple.postData.params.response)
Expand All @@ -22,10 +23,24 @@ module.exports = function (req, res, next) {
}
}

// overritten by application/x-www-form-urlencoded or multipart/form-data
if (req.simple.postData.text) {
try {
mock = JSON.parse(req.simple.postData.text)
} catch (e) {
debug(e)
}
}

// provide optional values before validation
mock.redirectURL = ''
mock.bodySize = 0
mock.headersSize = 0

if (!mock.content) {
mock.content = {}
}

mock.content.size = 0

validate.response(mock, function (err, valid) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"version": "1.5.0",
"name": "mockbin",
"description": "Test, mock, and track HTTP requests & responses between libraries, sockets and APIs",
"author": "Ahmad Nassri <[email protected]> (https://www.mashape.com/)",
Expand Down

0 comments on commit 6a85fc8

Please sign in to comment.