Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ChrisDolan (2855)

  (email not shown publicly)

Journal of ChrisDolan (2855)

Friday June 13, 2008
02:15 AM

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

[ #36679 ]


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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • 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.
  • 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 pat
    • 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.

      • 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 )