dougm       01/04/28 12:10:46

  Modified:    xs/Apache/RequestIO Apache__RequestIO.h
               xs/maps  modperl_functions.map
               xs/tables/current/ModPerl FunctionTable.pm
  Added:       t/api    sendfile.t
               t/response/TestAPI sendfile.pm
  Log:
  add $r->sendfile method and tests
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/api/sendfile.t
  
  Index: sendfile.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Test;
  use Apache::TestConfig ();
  
  plan tests => 3;
  
  my $config = Apache::TestConfig->thaw;
  
  my $url = '/TestAPI::sendfile';
  
  my $data = $config->http_raw_get($url);
  
  ok $data;
  
  my $module = 'response/TestAPI/sendfile.pm';
  
  ok length($data) == -s $module;
  
  $data = $config->http_raw_get("$url?noexist.txt");
  
  ok $data =~ /Not Found/;
  
  
  
  1.1                  modperl-2.0/t/response/TestAPI/sendfile.pm
  
  Index: sendfile.pm
  ===================================================================
  package TestAPI::sendfile;
  
  use strict;
  use warnings FATAL => 'all';
  
  sub handler {
      my $r = shift;
  
      my $file = $r->args || __FILE__;
  
      my $status = $r->sendfile($file);
  
      return $status == APR::SUCCESS ? Apache::OK : Apache::NOT_FOUND;
  }
  
  1;
  
  
  
  1.6       +30 -0     modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h
  
  Index: Apache__RequestIO.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Apache__RequestIO.h       2001/04/20 03:07:54     1.5
  +++ Apache__RequestIO.h       2001/04/28 19:10:44     1.6
  @@ -72,3 +72,33 @@
   
       return nrd;
   }
  +
  +static MP_INLINE
  +apr_status_t mpxs_Apache__RequestRec_sendfile(request_rec *r,
  +                                              const char *filename,
  +                                              apr_off_t offset,
  +                                              apr_size_t len)
  +{
  +    apr_size_t nbytes;
  +    apr_status_t status;
  +    apr_file_t *fp;
  +
  +    status = apr_file_open(&fp, filename, APR_READ|APR_BINARY,
  +                           APR_OS_DEFAULT, r->pool);
  +
  +    if (status != APR_SUCCESS) {
  +        return status;
  +    }
  +
  +    if (!len) {
  +        apr_finfo_t finfo;
  +        apr_file_info_get(&finfo, APR_FINFO_NORM, fp);
  +        len = finfo.size;
  +    }
  +
  +    status = ap_send_fd(fp, r, offset, len, &nbytes);
  +
  +    /* apr_file_close(fp); */ /* do not do this */
  +
  +    return status;
  +}
  
  
  
  1.7       +1 -0      modperl-2.0/xs/maps/modperl_functions.map
  
  Index: modperl_functions.map
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- modperl_functions.map     2001/04/20 03:07:55     1.6
  +++ modperl_functions.map     2001/04/28 19:10:44     1.7
  @@ -14,6 +14,7 @@
   MODULE=Apache::RequestIO   PACKAGE=Apache::RequestRec
    SV *:DEFINE_TIEHANDLE   | | SV *:stashsv, SV *:sv=Nullsv
    apr_size_t:DEFINE_PRINT | | ...
  + mpxs_Apache__RequestRec_sendfile | | r, filename=r->filename, offset=0, len=0
   
   MODULE=Apache::ServerUtil   PACKAGE=guess
    mpxs_Apache__Server_push_handlers
  
  
  
  1.9       +23 -1     modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm
  
  Index: FunctionTable.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FunctionTable.pm  2001/04/27 21:07:09     1.8
  +++ FunctionTable.pm  2001/04/28 19:10:45     1.9
  @@ -2,7 +2,7 @@
   
   # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   # ! WARNING: generated by ModPerl::ParseSource/0.01
  -# !          Fri Apr 27 14:00:37 2001
  +# !          Sat Apr 28 11:56:55 2001
   # !          do NOT edit, any changes will be lost !
   # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   
  @@ -3179,6 +3179,28 @@
         }
       ],
       'name' => 'mpxs_ap_get_client_block'
  +  },
  +  {
  +    'return_type' => 'apr_status_t',
  +    'args' => [
  +      {
  +        'name' => 'r',
  +        'type' => 'request_rec *'
  +      },
  +      {
  +        'name' => 'filename',
  +        'type' => 'const char *'
  +      },
  +      {
  +        'name' => 'offset',
  +        'type' => 'apr_off_t'
  +      },
  +      {
  +        'name' => 'len',
  +        'type' => 'apr_size_t'
  +      }
  +    ],
  +    'name' => 'mpxs_Apache__RequestRec_sendfile'
     }
   ];
   
  
  
  

Reply via email to