From e8fd02ca9e0998cc79337d0b94e72c7913b54c9a Mon Sep 17 00:00:00 2001 From: Drake Date: Thu, 28 Sep 2006 01:49:12 +0000 Subject: [PATCH] Fix HTTP Proxy asset file uploads. --- docs/changelog/7.x.x.txt | 5 ++++- lib/WebGUI.pm | 1 + lib/WebGUI/Asset/Wobject/HttpProxy.pm | 23 +++++++++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index be43e6365..462baf92e 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,3 +1,7 @@ +7.0.9 + - partial fix: invalid Message-ID headers in outgoing mail + - fix: HttpProxy not doing file uploads correctly + 7.0.8 - Fixed a couple of minor bugs with the default values of the Request Approval for Version Tag workflow activity. @@ -34,7 +38,6 @@ - fix: attachments section of post form not working correctly on edit - Images now create revisions as you resize them, so you can roll back to a previous size. - - partial fix: invalid Message-ID headers in outgoing mail 7.0.7 - rfe: Image Management (funded by Formation Design Systems) diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 3bb5cb118..ec929c78f 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -26,6 +26,7 @@ use WebGUI::Session; use WebGUI::User; use WebGUI::Utility; use WebGUI::PassiveProfiling; +use Apache2::Upload; use Apache2::Request; use Apache2::RequestRec (); use Apache2::RequestIO (); diff --git a/lib/WebGUI/Asset/Wobject/HttpProxy.pm b/lib/WebGUI/Asset/Wobject/HttpProxy.pm index 0d8d3c515..bb5ee0caa 100644 --- a/lib/WebGUI/Asset/Wobject/HttpProxy.pm +++ b/lib/WebGUI/Asset/Wobject/HttpProxy.pm @@ -257,7 +257,7 @@ sub view { $cookiebox =~ s/[^A-Za-z0-9\-\.\_]//g; #removes all funky characters $cookiebox .= '.cookie'; my $jar = HTTP::Cookies->new(File => $self->getCookieJar->getPath($cookiebox), AutoSave => 1, Ignore_Discard => 1); - my (%var, %formdata, @formUpload, $redirect, $response, $header, $userAgent, $proxiedUrl, $request); + my (%var, %formdata, $redirect, $response, $header, $userAgent, $proxiedUrl, $request); if($self->session->form->param("func")!~/editSave/i) { $proxiedUrl = $self->session->form->process("FormAction") || $self->session->form->process("proxiedUrl") || $self->get("proxiedUrl") ; @@ -311,18 +311,17 @@ sub view { my $contentType = 'application/x-www-form-urlencoded'; # default Content Type header # Create a %formdata hash to pass key/value pairs to the POST request - foreach my $input_name ($self->session->form->param) { - next if ($input_name !~ /^HttpProxy_/); # Skip non proxied form var's - $input_name =~ s/^HttpProxy_//; + foreach my $input_name ($self->session->request->param) { + $input_name =~ s/^HttpProxy_// or next; - my $uploadFile = $self->session->request->upload($self->session->form->process('HttpProxy_'.$input_name)); - if(-r $uploadFile) { # Found uploaded file - @formUpload=($uploadFile, $self->session->form->process('HttpProxy_'.$input_name)); - $formdata{$input_name}=\@formUpload; - $contentType = 'form-data'; # Different Content Type header for file upload - } else { - $formdata{$input_name}=$self->session->form->process('HttpProxy_'.$input_name); - } + my (@upload) = grep{defined} $self->session->request->upload('HttpProxy_'.$input_name); + if (@upload) { # Found uploaded file + my $upload = $upload[0]; + $formdata{$input_name}=[$upload->tempname, $self->session->form->process('HttpProxy_'.$input_name)]; + $contentType = 'form-data'; # Different Content Type header for file upload + } else { + $formdata{$input_name}=$self->session->form->process('HttpProxy_'.$input_name); + } } # Create POST request $request = HTTP::Request::Common::POST($proxiedUrl, \%formdata, Content_Type => $contentType);