You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by "Kratzer, James (Xetron)" <Ja...@ngc.com> on 2007/02/06 18:38:26 UTC
Input filter cannot change size of multipart/form-data
Please help.
I have an input filter that looks for the Content-Type
"multipart/form-data" and saves the whole POST request to disk for
processing by scripts invoked by the filter. The processed
multipart/form-data is then read back in and sent up the chain.
Here are the steps for my input filter:
1. If a multipart/form-data post is found then save it to disk.
2. Execute a script to process the multipart/form-data.
3. Read the processed multipart/form data in, put it into the brigade,
and send it on up the chain.
4. If the size of the new multpart/form-data has changed then my filter
changes the Content-Length header in the headers_in table.
Everything works as long as I don't change the size of the
multipart/form-data. It appears that if I change the size of the
multipart/form-data post(such as replacing an attachment with either a
smaller or larger attachment than the original), then the post dies even
though I'm updating the Content-Length in headers_in. Why can't I
change the size of the multipart/form-data post.
Thanks,
JK
RE: Input filter cannot change size of multipart/form-data
Posted by "Kratzer, James (Xetron)" <Ja...@ngc.com>.
Hi,
I've looked at mod_upload and if I understand it correctly, mod_upload
is removing attachments from multipart/form-data posts and sending them
up the chain and putting the other fields of the mime encoded
multipart/form-data into a table which is part of the request record. I
don't see the Content-Length in headers_in being changed anywhere in the
module. Why does mod_upload not need to change the Content-Length?
In my filter, I'm changing the Content-Length right after the scripts
are done processing the multipart/form-data which was saved to /tmp as
so:
1. Save multipart/form-data to /tmp
2. Invoke scripts to process multipart/form-data
3. Read processed multipart/form-data from /tmp and put into brigade.
4. >>>>>> Update Content-Length in headers_in <<<<<
5. Insert EOS into brigade
6. return APR_SUCCESS.
Any hints?
Thanks
-----Original Message-----
From: Nick Kew [mailto:nick@webthing.com]
Sent: Tuesday, February 06, 2007 12:55 PM
To: modules-dev@httpd.apache.org
Subject: Re: Input filter cannot change size of multipart/form-data
On Tue, 6 Feb 2007 12:38:26 -0500
"Kratzer, James \(Xetron\)" <Ja...@ngc.com> wrote:
> Please help.
>
> I have an input filter that looks for the Content-Type
> "multipart/form-data" and saves the whole POST request to disk for
> processing by scripts invoked by the filter. The processed
> multipart/form-data is then read back in and sent up the chain.
Is mod_upload not any use to you?
> Everything works as long as I don't change the size of the
> multipart/form-data. It appears that if I change the size of the
> multipart/form-data post(such as replacing an attachment with either a
> smaller or larger attachment than the original), then the post dies
> even though I'm updating the Content-Length in headers_in. Why can't
> I change the size of the multipart/form-data post.
*When* are you changing the header in headers_in?
I expect you might want to look at the note on order of processing in my
article at http://www.apachetutor.org/dev/request
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
RE: Input filter cannot change size of multipart/form-data
Posted by "Kratzer, James (Xetron)" <Ja...@ngc.com>.
The problem I'm having is a bug in mod_proxy which has been fixed in
2.0.55 and later as described in the link below. I was using 2.0.52
which is what comes with RHEL 4. Updating to 2.0.55 fixed my problem.
http://mail-archives.apache.org/mod_mbox/httpd-dev/200212.mbox/%3C214748
3647.1038876761@localhost%3E
The problem is that mod_proxy generates the Content-Length header before
calling the input filters. If an input filter modifies the body of the
request, as my filter does, mod_proxy does not regenerate the
Content-Length header. A fix was made in mod_proxy to delay generating
the Content-Length header until after the input filters are called.
Just wanted to give others an update
JK
-----Original Message-----
From: Nick Kew [mailto:nick@webthing.com]
Sent: Tuesday, February 06, 2007 12:55 PM
To: modules-dev@httpd.apache.org
Subject: Re: Input filter cannot change size of multipart/form-data
On Tue, 6 Feb 2007 12:38:26 -0500
"Kratzer, James \(Xetron\)" <Ja...@ngc.com> wrote:
> Please help.
>
> I have an input filter that looks for the Content-Type
> "multipart/form-data" and saves the whole POST request to disk for
> processing by scripts invoked by the filter. The processed
> multipart/form-data is then read back in and sent up the chain.
Is mod_upload not any use to you?
> Everything works as long as I don't change the size of the
> multipart/form-data. It appears that if I change the size of the
> multipart/form-data post(such as replacing an attachment with either a
> smaller or larger attachment than the original), then the post dies
> even though I'm updating the Content-Length in headers_in. Why can't
> I change the size of the multipart/form-data post.
*When* are you changing the header in headers_in?
I expect you might want to look at the note on order of processing in my
article at http://www.apachetutor.org/dev/request
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
Re: Input filter cannot change size of multipart/form-data
Posted by Nick Kew <ni...@webthing.com>.
On Tue, 6 Feb 2007 12:38:26 -0500
"Kratzer, James \(Xetron\)" <Ja...@ngc.com> wrote:
> Please help.
>
> I have an input filter that looks for the Content-Type
> "multipart/form-data" and saves the whole POST request to disk for
> processing by scripts invoked by the filter. The processed
> multipart/form-data is then read back in and sent up the chain.
Is mod_upload not any use to you?
> Everything works as long as I don't change the size of the
> multipart/form-data. It appears that if I change the size of the
> multipart/form-data post(such as replacing an attachment with either a
> smaller or larger attachment than the original), then the post dies
> even though I'm updating the Content-Length in headers_in. Why can't
> I change the size of the multipart/form-data post.
*When* are you changing the header in headers_in?
I expect you might want to look at the note on order
of processing in my article at
http://www.apachetutor.org/dev/request
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/