mjackson / mjackson/strata

it is different between curl post and form post

Open
#44 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
364
Forks
33
PR merge metrics
No merged PRs in 30d

Description

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"

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at strata.Request(env) and its req.body callback, reproducing both the curl command and the HTML form submission shown in the issue. Compare the body formats received by the two paths; the work is done when form data is parsed consistently with the curl POST.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.