Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support requests containing form data #159

Open
jbailey4 opened this issue May 27, 2016 · 4 comments
Open

support requests containing form data #159

jbailey4 opened this issue May 27, 2016 · 4 comments

Comments

@jbailey4
Copy link

jbailey4 commented May 27, 2016

How should requests with form data be handled? Is there a way to parse form data with pretender?
Currently in the FakeRequest containing form data the request body looks like the following:

requestBody: "foo=bar&baz=someValue"

@dustinfarris
Copy link
Contributor

i am curious about this as well

@crodriguez1a
Copy link

@jbailey4 I'm also running into a similar issue. Any traction on this?

@trek
Copy link
Member

trek commented Aug 25, 2016

Parsing form data into language-specific objects is not handled identically across application servers. At a cursory investigation a while back there were so many small differences that it didn't seem reliable to include this in Pretender without spawning a list of Issues related to "parses X wrong" (where "wrong" means "not like the server application library I am communicating with in production").

Indeed, just for nodejs, there are several competing body parsers that all return slightly different outputs for url encoded form bodies: https://github.com/expressjs/body-parser#bodyparserurlencodedoptions, https://www.npmjs.com/package/body#readme, https://github.com/Raynos/body, https://www.npmjs.com/package/co-body#readme

I'd be happy to recommend in the README a set of HTML encoded parsers that match the parsers people are using!

@jbailey4
Copy link
Author

@trek Agreed. I think adding some docs on this in the README and mentioning parsing request bodies should be handled according to your environment setup will be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants