http://qs321.pair.com?node_id=11112338

FeistyLemur has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, so I have a bit of code that was previously working fine and for no reason I can find an explanation to has stopped working. Basically I am doing a firmware file upload to a device via http. I've used this code many times in the past, even on the same test device and now it fails with a corrupt file error message from the device. Below is the relevant snip for the file upload. It's a much larger script with other parts for configuration, so I've tried to just carve out the upload here for an example.

use LWP::UserAgent(); use HTTP::CookieJar::LWP(); ## Create browser object. my $jar = HTTP::CookieJar::LWP->new; my $ua = LWP::UserAgent->new( keep_alive=>200, cookie_jar => $jar, protocols_allowed => ['http', 'https'], timeout => 60, ); my $client='xxx.xxx.xxx.xxx'; my $username='username'; my $password'password'; my $fw_file='/home/location/file.bin'; my $xsrf=auth($client, $username, $password); ##xsrf session token is +provided by separate authentication sub. my $results=upgrade($client, $fw_file); sub upgrade { ## Upload file. my ($client,$fw_file)=@_; my $res=$ua->post("http://$client/upload.cgi?xsrf=$xsrf", [ 'upfile' => ["$fw_file"], 'Submit_button' => 'Upload+Software+Image', ], Content_Type => 'form-data', ); ##Continues on to other steps from here. ##This post fails where it worked previously. }

All the documentation and examples I've found have suggested posting file uploads to http in this way and it worked for ages, I would have to assume system package updates changed the way things are working, as the device being uploaded to has not changed in any way. Any thoughts about what might be handled better in this method?