HTTP::Body vs. Test::WWW::Mechanize::Catalyst

ChrisDolan on 2008-06-13T07:15:56

Lazyweb:

Catalyst uses HTTP::Body to decode incoming HTTP requests. This is particularly important for HTML form-based file uploads. It works great for me in any browser and when uploading text files. But when uploading binary files via Test::WWW::Mechanize::Catalyst, HTTP::Body over-reads the MIME part and drops the file upload.

I suspect its a problem with byte-length vs. character-length of a string, where my request has some UTF-8ness going on in the Test::W::M::C workflow (where the request never actually goes over the wire -- it stays in the same Perl process the whole time).

Has anyone else encountered this? I posted a workaround request to RT for HTTP::Body, but I'm not sure who's really at fault here: me, HTTP::Body or T::W::M::C.


happening to me too

dhsonny on 2008-06-23T06:37:01

Hi Chris, Oddly enough ( or not so oddly enough ) this is happening to me too. The interesting thing is that I was able to upload files using WWW::Mechanize::Shell and Test::WWW::Mechanize so I'm guessing you are not the problem.

Easy work around

dhsonny on 2008-06-24T04:06:02

Hi Chris, After some rudimentary digging around I'm fairly sure this is in &T::W::M::C::_make_request. If you set $mech->allow_external(1) and add your port to the URL you are trying to test, it falls back to the W::M::_make_request implementation and everything works great. Since Test::Catalyst starts your application it is in fact listening on the dev port (whatever port you have selected, default 3000 ) and the request will succeed. Not very portable but it works until I can figure out how to patch T::W::M::C. -s

Re:Easy work around

ChrisDolan on 2008-06-24T05:22:26

Thanks for the info. I'm using my own hack -- Base64 encoding the uploaded file and doing a special-case decode server-side -- which is working well enough for the moment.

If you or I can isolate the problem far enough, one of us should write it up as an RT bug report.

Re:Easy work around

dhsonny on 2008-06-24T05:29:35

I talked to the package maintainer this morning and he asked me to patch it if I could. Seems he's swamped with other stuff. I'll look into getting a patch out sometime next month. ( Hopefully I can find the exact cause in a week or two )