httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Wichitill <ma...@gmx.de>
Subject [apreq-2] Open upload with or without :APR
Date Thu, 22 Jul 2004 13:13:23 GMT
We still need to decide when to use :APR and when not in $upload->fh, and 
when to tell users to use :APR for $upload->tempname and $upload->link.

After re-reading the related thread 
(http://article.gmane.org/gmane.comp.apache.apreq/2010), I think we only 
actually need :APR on Windows, right? We don't need to care about more 
complicated has_large_files_conflict() stuff on Unix, since :APR is only 
needed to set those two special Win32 file flags.

So how about these simple "if ($^O =~ /Win32/)" patches?


Index: glue/perl/xsbuilder/Apache/Upload/Upload_pm
===================================================================
RCS file: 
/home/cvspublic/httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Upload_pm,v
retrieving revision 1.10
diff -u -r1.10 Upload_pm
--- glue/perl/xsbuilder/Apache/Upload/Upload_pm	8 Jul 2004 19:55:57 -0000	1.10
+++ glue/perl/xsbuilder/Apache/Upload/Upload_pm	22 Jul 2004 10:53:48 -0000
@@ -14,8 +14,15 @@

  sub fh {
      my $upload = shift;
-    open my $fh, "<:APR", $upload->tempname, $upload->pool or
-        die "Can't open ", $upload->tempname, ": ", $!;
+    my $fh;
+    if ($^O =~ /Win32/) {
+      open $fh, "<:APR", $upload->tempname, $upload->pool
+          or die "Can't open ", $upload->tempname, ": ", $!;
+    }
+    else {
+      open $fh, "<", $upload->tempname
+          or die "Can't open ", $upload->tempname, ": ", $!;
+    }
      return $fh;
  }



Index: glue/perl/t/response/TestApReq/upload.pm
===================================================================
RCS file: 
/home/cvspublic/httpd-apreq-2/glue/perl/t/response/TestApReq/upload.pm,v
retrieving revision 1.1
diff -u -r1.1 upload.pm
--- glue/perl/t/response/TestApReq/upload.pm	12 Jul 2004 13:10:14 -0000	1.1
+++ glue/perl/t/response/TestApReq/upload.pm	22 Jul 2004 11:07:37 -0000
@@ -31,8 +31,14 @@
      }
      elsif ($method eq 'tempname') {
          my $name = $upload->tempname;
-        open $fh, "<:APR", $name, $upload->pool
-            or die "Can't open $name: $!";
+        if ($^O =~ /Win32/) {
+            open $fh, "<:APR", $name, $upload->pool
+                or die "Can't open $name: $!";
+        }
+        else {
+            open $fh, "<", $name
+                or die "Can't open $name: $!";
+        }
          binmode $fh;
          read $fh, $data, $upload->size;
          close $fh;
@@ -41,7 +47,14 @@
          my $link_file = File::Spec->catfile($temp_dir, "linkfile");
          unlink $link_file if -f $link_file;
          $upload->link($link_file) or die "Can't link to $link_file: $!";
-        open $fh, "<", $link_file or die "Can't open $link_file: $!";
+        if ($^O =~ /Win32/) {
+            open $fh, "<:APR", $link_file, $upload->pool
+                or die "Can't open $link_file: $!";
+        }
+        else {
+            open $fh, "<", $link_file
+                or die "Can't open $link_file: $!";
+        }
          binmode $fh;
          read $fh, $data, $upload->size;
          close $fh;


Index: glue/perl/t/response/TestApReq/request.pm
===================================================================
RCS file: 
/home/cvspublic/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
retrieving revision 1.33
diff -u -r1.33 request.pm
--- glue/perl/t/response/TestApReq/request.pm	18 Jul 2004 23:24:51 -0000	1.33
+++ glue/perl/t/response/TestApReq/request.pm	22 Jul 2004 11:49:29 -0000
@@ -72,8 +73,15 @@
          chop $dir;
          die "Tempfile in wrong temp_dir (expected $temp_dir, saw $dir)" unless
              $dir eq $temp_dir;
-
-        open my $fh, "<:APR", $name, $upload->pool or die "Can't open 
$name: $!";
+				my $fh;
+        if ($^O =~ /Win32/) {
+            open $fh, "<:APR", $name, $upload->pool
+                or die "Can't open $name: $!";
+        }
+        else {
+            open $fh, "<", $name
+                or die "Can't open $name: $!";
+        }
          $r->print(<$fh>);
      }
      elsif ($test eq 'link') {
@@ -81,7 +89,15 @@
          my $link_file = File::Spec->catfile("$temp_dir", "linktest");
          unlink $link_file if -f $link_file;
          $upload->link($link_file) or die "Can't link to $link_file: $!";
-        open my $fh, "<", $link_file or die "Can't open $link_file: $!";
+				my $fh;
+        if ($^O =~ /Win32/) {
+            open $fh, "<:APR", $link_file, $upload->pool
+                or die "Can't open $link_file: $!";
+        }
+        else {
+            open $fh, "<", $link_file
+                or die "Can't open $link_file: $!";
+        }
          $r->print(<$fh>);
      }
      elsif ($test eq 'fh') {


Regarding the last chunk: for the link test in request.pm to succeed, I 
didn't actually need the :APR on Win32, unlike for the link test in 
upload.pm. I'm not sure why, but I guess using the same code can't hurt.

On Win32 Perl 5.8 is required anyway and the AS binaries used by most people 
have PerlIO enabled. Both the AS binaries and the official Apache binaries 
have largefiles support. So unless someone compiles Perl without PerlIO or 
Perl and Apache with diverging largefile support, Win32 users should be able 
to use :APR.

Of course it's still not possible to simply pass $upload->tempname to 
someone's Perl module or external program (which is was what the person that 
requested tempname on the mp list wanted) and be Win32-compatible.

Mime
View raw message