While this approach made sense to me, it didn't turn out to work as expected. It looks like the CGI.pm "new" function is expecting a basic name/value format from the file handle, and can't currently handle a raw
HTTP POST request.
Another approach that occured to me is to capture the environment variables of a real HTTP POST, and then set them again inside the test script.