From ee9c39ca6f2b63d84871b7ad4053a0f68749d920 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sun, 15 Jul 2018 21:36:29 +0200 Subject: [PATCH] Avoid calling $r->request_body repeatedly --- upload.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/upload.pm b/upload.pm index 2cfd615..75353cc 100644 --- a/upload.pm +++ b/upload.pm @@ -133,13 +133,17 @@ sub handle_put_body { $r->log_error($!, "Cannot set binary mode for $file_path"); return HTTP_INTERNAL_SERVER_ERROR; } - if ($r->request_body) { - if (not syswrite($fh, $r->request_body)) { + + my $request_body = $r->request_body; + my $request_body_file = $r->request_body_file; + + if ($request_body) { + if (not syswrite($fh, $request_body)) { $r->log_error($!, "Cannot write $file_path"); return HTTP_INTERNAL_SERVER_ERROR; } - } elsif ($r->request_body_file) { - if (not move($r->request_body_file, $fh)) { + } elsif ($request_body_file) { + if (not move($request_body_file, $fh)) { $r->log_error($!, "Cannot move data to $file_path"); return HTTP_INTERNAL_SERVER_ERROR; }