You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by "David N. Welton" <da...@apache.org> on 2001/06/20 16:45:26 UTC

multiple files with the same name, .h file changes

I'd like to propose this, to stay consistent - if we have _find,
_type, _info, we might as well do them all.

--- /home/davidw/workshop/httpd-apreq/c/apache_request.h        Tue Jun 19 12:17:10 2001
+++ apache_request.h    Wed Jun 20 13:58:48 2001
@@ -105,6 +105,11 @@
 #define ApacheRequest_upload(req) \
     ((req->parsed || (ApacheRequest_parse(req) == OK)) ? req->upload : NULL)
 
+
+#define ApacheUpload_FILE(upload) (upload->fp)
+
+#define ApacheUpload_size(upload) (upload->size)
+
 #define ApacheUpload_info(upload, key) \
 ap_table_get(upload->info, key)


_FILE could be _fp too.  It's more consistent, but less descriptive.

Second thing... I'm puzzling over how to implement code to handle
multiple files uploaded with the same variable name.  It *is* legal,
and it's a pain in the ass.  apreq has some problems with it:

ApacheUpload *ApacheUpload_find(ApacheUpload *upload, char *name);

which will only get the first one.

I'd be curious to hear, briefly, how you perl guys deal with this, as
well as if you have any ideas on how we can (if needs be) improve
apreq to support this.

Thanks,
-- 
David N. Welton
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/
         Work: http://www.innominate.com/

Re: multiple files with the same name, .h file changes

Posted by "David N. Welton" <da...@apache.org>.
davidw@apache.org (David N. Welton) writes:

> Ok, I have a patch, below, that adds these as well as
> ApacheRequest_set_post_max, which I will commit early next week
> unless there are objects.  The relevant changes are at the bottom of
> the patch.

> I also went through quickly and killed some extraneous white space
> (s/[:space:]+$//, more or less).

Done.

-- 
David N. Welton
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/
         Work: http://www.innominate.com/

Re: multiple files with the same name, .h file changes

Posted by "David N. Welton" <da...@apache.org>.
Joe Schaefer <jo...@sunstarsys.com> writes:

> davidw@apache.org (David N. Welton) writes:
> 
> > +
> > +#define ApacheUpload_FILE(upload) (upload->fp)
> > +
> > +#define ApacheUpload_size(upload) (upload->size)
> > +
> >  #define ApacheUpload_info(upload, key) \
> >  ap_table_get(upload->info, key)

> > _FILE could be _fp too.  It's more consistent, but less descriptive.
 
> Looks ok to me- I have no opinion on which of _FILE or _fp is
> preferable.

Ok, I have a patch, below, that adds these as well as
ApacheRequest_set_post_max, which I will commit early next week unless
there are objects.  The relevant changes are at the bottom of the
patch.

I also went through quickly and killed some extraneous white space
(s/[:space:]+$//, more or less).
 
> We provide a means to iterate over the upload table in Request.xs.
> Here's a snippet from Request.xs (xs files are mostly C code with
> some perl glue macros):

Thanks!
-- 
David N. Welton
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/
         Work: http://www.innominate.com/


Re: multiple files with the same name, .h file changes

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Joe Schaefer <jo...@sunstarsys.com> writes:

> We provide a means to iterate over the upload table in Request.xs.  
                                         ^^^^^^^^^^^^

It's not an apache table, just a singly linked list.  That's why the 
perl $apr->param interface is a little different from $apr->upload one.

Sorry if that caused any confusion.

-- 
Joe Schaefer


Re: multiple files with the same name, .h file changes

Posted by Joe Schaefer <jo...@sunstarsys.com>.
davidw@apache.org (David N. Welton) writes:

> +
> +#define ApacheUpload_FILE(upload) (upload->fp)
> +
> +#define ApacheUpload_size(upload) (upload->size)
> +
>  #define ApacheUpload_info(upload, key) \
>  ap_table_get(upload->info, key)
> 
> 
> _FILE could be _fp too.  It's more consistent, but less descriptive.

Looks ok to me- I have no opinion on which of _FILE or _fp is 
preferable.

> 
> Second thing... I'm puzzling over how to implement code to handle
> multiple files uploaded with the same variable name.  It *is* legal,
> and it's a pain in the ass.  apreq has some problems with it:
> 
> ApacheUpload *ApacheUpload_find(ApacheUpload *upload, char *name);
> 
> which will only get the first one.
> 
> I'd be curious to hear, briefly, how you perl guys deal with this, as
> well as if you have any ideas on how we can (if needs be) improve
> apreq to support this.

We provide a means to iterate over the upload table in Request.xs.  
Here's a snippet from Request.xs (xs files are mostly C code with some
perl glue macros):

	for (uptr = req->upload; uptr; uptr = uptr->next) {
	    upload_push(uptr);

This builds a return list of upload table entries, which the user
would get at by calling

  @upload_list = $apr->upload; # list context

We also offer a perl API to upload->next, so the user can iterate 
over the upload objects themselves:

  # $apr->upload called in scalar context returns first upload object

  for ( my $up = $apr->upload; $up; $up = $up->next ) {
    # check $up->name, $up->filename, etc.
  }


We use a more user-friendly approach for multi-valued parameters, 
though. If the form has many values for the parameter "key", then
the user can get at them all by

  @values = $apr->param("key"); # list of values

The relevant code in Request.xs is around lines 415 - 430. We could
do something similar with $apr->upload("key"), but we currently don't.

-- 
Joe Schaefer