forms icon indicating copy to clipboard operation
forms copied to clipboard

Add Multipart support for fields

Open mdab121 opened this issue 7 years ago • 4 comments

I was trying to use vapor-forms in a multipart post request, using it for everything except the actual uploaded file (handled that on my own). I don't know why, but if the form is posted as multipart, none of the fieldset parsers actually see any content.

content[fieldName] as? Node returns nil. But somehow, content[fieldName]?.string returns a valid string.

This PR checks for that form of parsing as well.

mdab121 avatar Mar 27 '17 07:03 mdab121

Thanks very much for this! Would you be able to add a test which fails without, and passes with, your new addition? The existing test testSampleLoginFormWithMultipart is supposed to catch multipart requests and it still passes, though I believe Vapor has a rewritten multipart handler so that might explain things.

bygri avatar Mar 27 '17 10:03 bygri

I think this issue only arises only if the request is actually multipart (mixed validatable form data and files). In those cases, content is parsed lazily in Vapor I guess.

Anyway, I have no idea how to fake an actual multipart request. I'd have to fake a real browser, and send a real file via a multipart form, or at least use internal Vapor APIs to join request slices together. Do you think those Vapor implementation dependent tests would be a good idea? I'm not sure...

mdab121 avatar Mar 28 '17 23:03 mdab121

Ping :)

mdab121 avatar Apr 04 '17 17:04 mdab121

Sorry mate. PR #10 has added broken dependencies which caused the build to start failing and I have avoided making any further changes to this repo until Vapor 2 is out. If you need this in the meantime, could you manage by pointing to your own fork?

bygri avatar Apr 05 '17 00:04 bygri