mjackson / strata

A modular, streaming HTTP server for node.js
http://stratajs.org
366 stars 35 forks source link

it is different between curl post and form post #44

Open enginespot opened 11 years ago

enginespot commented 11 years ago
strata.get("/register", function(env, callback) {
  var content;
  content = "";
  content += "<form action=\"/register\" method=\"post\" enctype=\"text/plain\">";
  content += "<input name=\"name\" type=\"text\">";
  content += "<input name=\"password\" type=\"password\">";
  content += "<input type=\"submit\" value=\"Register\">";
  content += "</form>";
  callback(200, {}, content);
});

strata.post("/register", function(env, callback) {
  var req;
  req = strata.Request(env);
  req.body(function(err, body) {
    if (err && strata.handleError(err, env, callback)) {
      return;
    }
    console.log(body);
  });
});

when I use curl post curl -v --data "name=a&password=b" http://localhost:3000/register

the data parsed to a json data

but when I use form submit

the data does not parsed , it is string "name=a password=b"