johntitus / node-horseman

Run PhantomJS from Node
MIT License
1.45k stars 124 forks source link

post multi-form data #61

Open joernroeder opened 9 years ago

joernroeder commented 9 years ago

do you have any plans to add support for multipart/form-data (Multipart Form Uploads)?

johntitus commented 9 years ago

If someone knows how to do it with PhantomJS, I can look into adding it.

awlayton commented 9 years ago

PhantomJS has support for sending whatever encoding you want, but you have to encode the data yourself.

johntitus commented 9 years ago

I wonder if we could provide a built-in way to do it. Maybe there's a node module to take a json object and turn it into a form encoded object or something.

awlayton commented 9 years ago

I'm not sure how the interface would look. With multipart/form-data, you can specify headers for each part of the body.

joernroeder commented 9 years ago

I've found casperjs and it's .fillForm function which can handle file uploads and therefore multipart/form-dataforms. Maybe that's a good starting point…

awlayton commented 9 years ago

If a form exists on the page , the function should be able to just manipulate the DOM to fill it out and submit it. I was originally envisioning some more like horseman's current .post that would not rely on there actually being a form to fill.

I am not sure which version is "better", whatever that means.

awlayton commented 8 years ago

I think I will add an action for filling (and submitting?) a form on the page simmilar to the CasperJS .fill() as a todo for v3.

I am also considering something like allowing giving an object to .post() and having horseman multipart/form-data encode it.

Do either/both of these sound good @joernroeder and @johntitus?

awlayton commented 8 years ago

Looks like https://www.npmjs.com/package/form-data or https://www.npmjs.com/package/form-urlencoded might be useful for this.

awlayton commented 8 years ago

How do you think this should work @wong2? The .fill() way, the .post() way, or something else?