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 Oskari 'Okko' Ojala <so...@okko.net> on 2003/04/13 13:37:25 UTC

[PATCH] to accept file uploads from Nokia Series 60 phones

Summary:

Libapreq expects a "filename" parameter in multipart/form-data to detect 
a part is a file upload. Nokia Series 60 phones use "Filename" 
parameter (uppercase F) when uploading photos from the Photos 
application. This patch changes the libapreq to accept both "filename" 
and "Filename".

The Nokia Series 60 phones (Nokia 7650, Nokia 3650) include a 
built-in Photos application. The application has a "Send photo" feature 
to upload selected photos to the server using POST. The application uses 
"Filename" parameter in POST data. Because of this, the uploaded files 
don't show up as Apache::Upload objects in Perl.


The patch:

--- apache_request_rev1.23.c    Sun Apr 13 13:47:35 2003
+++ apache_request.c    Sun Apr 13 13:48:31 2003
@@ -568,7 +568,7 @@
                    if(strEQ(key, "name")) {
                        param = ap_getword_conf(r->pool, &pair);
                    }
-                   else if(strEQ(key, "filename")) {
+                   else if(strEQ(key, "filename") || strEQ(key, "Filename")) {
                        filename = ap_getword_conf(r->pool, &pair);
                    }
                }



References:

RFC 2388.

Nokia - Nokia 7650
	http://www.nokia.com/nokia/0,4879,137,00.html

Nokia - Nokia 3650
	http://www.nokia.com/nokia/0,4879,2273,00.html

Forum Nokia: Image Upload Server API v1.1
	http://www.nokia.com/nokia/0,4879,2273,00.html, search for
	"Image Upload" using the header search bar, select second
	file "Image Upload Server API v1.1".

Latest revision of apache_request.c of libapreq
	http://cvs.apache.org/viewcvs.cgi/httpd-apreq/c/apache_request.c?rev=1.23&content-type=text/vnd.viewcvs-markup



Other information:

RFC 2388 says:
   The original local file name may be supplied as well, either as a
   "filename" parameter either of the "content-disposition: form-data"
   header or, in the case of multiple files, in a "content-disposition:
   file" header of the subpart.


A caption of an IE POST with a file upload:

Content-Disposition: form-data; name="ImageData"; filename="Photo(21).jpg"
Content-Type: image/bmp


A caption of a Nokia Photo Upload POST with a file upload:

Content-Disposition: form-data; name="ImageData"; Filename="Photo(21).jpg"
Content-Type: image/jpeg


Own comments:
I don't know if this should be included in the main code or provided as 
an add-in patch elsewhere. You decide. :-)



	Oskari "Okko" Ojala

-- 


Re: [PATCH] to accept file uploads from Nokia Series 60 phones

Posted by Issac Goldstand <ma...@beamartyr.net>.
Don't think my vote counts, but for the record, I'm also +1 for commiting
the patch into the next release ASAP :-)

  Issac

----- Original Message -----
From: "Joe Schaefer" <jo...@sunstarsys.com>
To: "Oskari 'Okko' Ojala" <so...@okko.net>
Cc: <ap...@httpd.apache.org>
Sent: Sunday, April 13, 2003 7:13 PM
Subject: Re: [PATCH] to accept file uploads from Nokia Series 60 phones


> "Oskari 'Okko' Ojala" <so...@okko.net> writes:
>
> [...excellent summary...]
>
> > --- apache_request_rev1.23.c    Sun Apr 13 13:47:35 2003
> > +++ apache_request.c    Sun Apr 13 13:48:31 2003
> > @@ -568,7 +568,7 @@
> >               if(strEQ(key, "name")) {
> >                   param = ap_getword_conf(r->pool, &pair);
> >               }
> > -             else if(strEQ(key, "filename")) {
> > +             else if(strEQ(key, "filename") || strEQ(key, "Filename"))
{
> >                   filename = ap_getword_conf(r->pool, &pair);
> >               }
> >           }
>
> Thanks alot!  I'm +1 for having this functionality in libapreq-1.2,
> but perhaps we should be using a case-insensitive test (like strcasecmp)
> instead of strEQ in this section of code.
>
> [...]
>
> > Other information:
> >
> > RFC 2388 says:
> >    The original local file name may be supplied as well, either as a
> >    "filename" parameter either of the "content-disposition: form-data"
> >    header or, in the case of multiple files, in a "content-disposition:
> >    file" header of the subpart.
>
> We actually don't have any code for handling the "multiple files" case
> mentioned above.  I think that's a feature best reserved for
httpd-apreq-2.
> It should be pretty straightforward to modify/reuse
apreq_parse_multipart()
> to generate a brigade which represents the "multiple files" case.  The
> apreq-2 parsers are all reentrant (hopefully :-).
>
> > A caption of an IE POST with a file upload:
> >
> > Content-Disposition: form-data; name="ImageData";
filename="Photo(21).jpg"
> > Content-Type: image/bmp
>                 ^^^^^^^^^
^^^
>
> Interesting- the Content-Type appears to be incorrect here, no?
> Good luck on submitting a bugfix to M$ :-).
>
> Thanks again!
> --
> Joe Schaefer
>


Re: [PATCH] to accept file uploads from Nokia Series 60 phones

Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Oskari 'Okko' Ojala" <so...@okko.net> writes:

> On 13 Apr 2003, Joe Schaefer wrote:
> 
> > Thanks alot!  I'm +1 for having this functionality in libapreq-1.2, 
> > but perhaps we should be using a case-insensitive test (like strcasecmp)
> > instead of strEQ in this section of code.
> 
> Whichever is faster. :) Then again, next up there may be a browser 
> sending "FILENAME" or "FileName", so case-insensitive comparing might be 
> best..

That's what I was thinking.  Parsing the Content-Disposition header is
such a small, yet critical, part of the mfd parser that I'd rather err 
on the side of flexibility here.  Even though a case-insensitive
comparison will theoretically be slower, I don't believe the overall 
performance impact on the mfd parser will even be noticeable.

OTOH, I just patched the apreq-2 core to use case-insensitive matches 
here, so maybe I've already prejudiced the discussion somewhat :-).

-- 
Joe Schaefer

Re: [PATCH] to accept file uploads from Nokia Series 60 phones

Posted by Oskari 'Okko' Ojala <so...@okko.net>.
On 13 Apr 2003, Joe Schaefer wrote:

> Thanks alot!  I'm +1 for having this functionality in libapreq-1.2, 
> but perhaps we should be using a case-insensitive test (like strcasecmp)
> instead of strEQ in this section of code.

Whichever is faster. :) Then again, next up there may be a browser 
sending "FILENAME" or "FileName", so case-insensitive comparing might be 
best..

> We actually don't have any code for handling the "multiple files" case
> mentioned above.

Actually, I think the RFC means "in the case of multiple parts" there. The 
phone sends a couple of other fields too, but only one file upload per POST.

Anyway, without the patch I see no Apache::Upload object in Perl, with 
the patch I do. But the phone uploads them one-photo-by-POST-request, so 
I haven't experimented with multiple files in same request.

> > Content-Disposition: form-data; name="ImageData"; filename="Photo(21).jpg"
> > Content-Type: image/bmp
>                 ^^^^^^^^^                                               ^^^
> 
> Interesting- the Content-Type appears to be incorrect here, no?
> Good luck on submitting a bugfix to M$ :-).

Oops. I just replaced my local file name from my message and got 
caught! :) IE does send the correct content type and the full path 
of the file in the "filename" parameter. :)

The main point was that IE uses "filename" and the Nokia phone "Filename". 

Before submitting the patch to the list I captured phone's and IE's POSTs 
with netcat, then used netcat to submit the POSTs to the server with both 
"filename" and "Filename". Before the patch, "filename" worked and 
"Filename" didn't. After both worked.


	Oskari "Okko" Ojala

-- 




Re: [PATCH] to accept file uploads from Nokia Series 60 phones

Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Oskari 'Okko' Ojala" <so...@okko.net> writes:

[...excellent summary...]

> --- apache_request_rev1.23.c    Sun Apr 13 13:47:35 2003
> +++ apache_request.c    Sun Apr 13 13:48:31 2003
> @@ -568,7 +568,7 @@
>               if(strEQ(key, "name")) {
>                   param = ap_getword_conf(r->pool, &pair);
>               }
> -             else if(strEQ(key, "filename")) {
> +             else if(strEQ(key, "filename") || strEQ(key, "Filename")) {
>                   filename = ap_getword_conf(r->pool, &pair);
>               }
>           }

Thanks alot!  I'm +1 for having this functionality in libapreq-1.2, 
but perhaps we should be using a case-insensitive test (like strcasecmp)
instead of strEQ in this section of code.

[...]

> Other information:
> 
> RFC 2388 says:
>    The original local file name may be supplied as well, either as a
>    "filename" parameter either of the "content-disposition: form-data"
>    header or, in the case of multiple files, in a "content-disposition:
>    file" header of the subpart.

We actually don't have any code for handling the "multiple files" case
mentioned above.  I think that's a feature best reserved for httpd-apreq-2.
It should be pretty straightforward to modify/reuse apreq_parse_multipart() 
to generate a brigade which represents the "multiple files" case.  The
apreq-2 parsers are all reentrant (hopefully :-).

> A caption of an IE POST with a file upload:
> 
> Content-Disposition: form-data; name="ImageData"; filename="Photo(21).jpg"
> Content-Type: image/bmp
                ^^^^^^^^^                                               ^^^

Interesting- the Content-Type appears to be incorrect here, no?
Good luck on submitting a bugfix to M$ :-).

Thanks again!
-- 
Joe Schaefer