You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Werner Schalk <we...@gmx.de> on 2002/08/22 23:52:03 UTC

content length header in ExtFilterDefine

Hello,

is it possible to send an content length
header before sending the output of
an external filter to a client?

How can I do this? If it is not possible,
could such a feature be added to
ExtFilterDefine please?

I coded a filter which works fine
for netscape but internet exploder wants this
content length header to be set before
showing the results of my filter :-(

Bye and thanks,
Werner.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: content length header in ExtFilterDefine

Posted by Werner Schalk <we...@gmx.de>.
Hi again,

this is what I did:

skywalk:/usr/local/apache2/htdocs# telnet localhost 80
Trying 127.0.0.1...
Connected to diebels.
Escape character is '^]'.
GET /test.html HTTP/1.1
Host: localhost
Range: bytes=100-200

HTTP/1.1 206 Partial Content
Date: Fri, 23 Aug 2002 15:23:58 GMT
Server: Apache/2.0.40 (Unix)
Last-Modified: Thu, 22 Aug 2002 21:48:01 GMT
ETag: "23b3ab-1a2-e0126640"
Accept-Ranges: bytes
Content-Range: bytes 100-200/2965
Content-Length: 101
Content-Type: application/pdf

{
®C¨í
û¨e^[[AConnection closed by foreign host.

Are there more ways to test this feature/bug?

Bye,
Werner.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: content length header in ExtFilterDefine

Posted by Joshua Slive <jo...@slive.ca>.
Werner Schalk wrote:
> Hello,
> 
> how can I manually perform a range request?
> I would really like to report this as a bug
> if it is one...

I'm not really an expert in this, but it would probably look something like

telnet localhost 80
GET /file HTTP/1.1
Host: localhost
Range: bytes=100-200

And the server should then return only bytes 100 through 200 of the 
response.

> 
> Sebastian and I think txt->pdf output filter
> will be really great...wouldn't it?

Sure.  Performance of external filters is always going to be mediocre 
(about the same as CGI scripts), but it should still be useful.  In any 
case, if range requests aren't working, that is a bug that should be fixed.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: content length header in ExtFilterDefine

Posted by Werner Schalk <we...@gmx.de>.
Hello,

how can I manually perform a range request?
I would really like to report this as a bug
if it is one...

Sebastian and I think txt->pdf output filter
will be really great...wouldn't it?

Bye,
Werner.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: content length header in ExtFilterDefine

Posted by rb...@apache.org.
On Fri, 23 Aug 2002, Joshua Slive wrote:

> Sebastian Wolfgarten wrote:
> > Hello,
> > 
> > the content-length is set and even correct because
> > the size of the returned pdf document is exactly 2964 bytes.
> > And I have tested it again...netscape does it,
> > ie not :-(
> > 
> > I assume the content-length is set by the apache?
> 
> Yes, there is a content-length filter that will sometimes set the 
> content-length for you.
> 
> I suspect you are hitting some sort of a byte-range request problem. 
> These things can be quite difficult to debug, unfortunately.  My best 
> guess is that MSIE is making byte-range requests, and mod_ext_filter 
> doesn't know how to deal with them.  If you can test that (by manually 
> performing a range request), then you can report it as a bug.

mod_ext_filter doesn't need to know how to handle byterange requests,
there is a filter to do that.  Are you using the acrobat plug-in with
IE?  If so, you are definately making a byterange request.  What platform
is your Apache server on?  I'll try to debug this this weekend, but I am
strapped for time.  Please file a bug report at nagoya.apache.org.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: content length header in ExtFilterDefine

Posted by Joshua Slive <jo...@slive.ca>.
Sebastian Wolfgarten wrote:
> Hello,
> 
> the content-length is set and even correct because
> the size of the returned pdf document is exactly 2964 bytes.
> And I have tested it again...netscape does it,
> ie not :-(
> 
> I assume the content-length is set by the apache?

Yes, there is a content-length filter that will sometimes set the 
content-length for you.

I suspect you are hitting some sort of a byte-range request problem. 
These things can be quite difficult to debug, unfortunately.  My best 
guess is that MSIE is making byte-range requests, and mod_ext_filter 
doesn't know how to deal with them.  If you can test that (by manually 
performing a range request), then you can report it as a bug.

Joshua.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: content length header in ExtFilterDefine

Posted by Sebastian Wolfgarten <se...@gmx.net>.
Hello,

the content-length is set and even correct because
the size of the returned pdf document is exactly 2964 bytes.
And I have tested it again...netscape does it,
ie not :-(

I assume the content-length is set by the apache?

thanks and bye,
werner.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: content length header in ExtFilterDefine

Posted by Joshua Slive <jo...@slive.ca>.
Werner Schalk wrote:
> Hello,
> 
> I'm sorry I posted the wrong options,
> I did not use PreservesContentLength
> here! Anyway I use 2.0.40 of course.
> 
> Apache seems to send the headers
> correctly:
> 
> skywalk:/home/werner# lynx -head -dump http://localhost/test.html
> HTTP/1.1 200 OK
> Date: Fri, 23 Aug 2002 14:22:26 GMT
> Server: Apache/2.0.40 (Unix)
> Last-Modified: Thu, 22 Aug 2002 21:48:01 GMT
> ETag: "23b3ab-1a2-e0126640"
> Accept-Ranges: bytes
> Content-Length: 2964
> Connection: close
> Content-Type: application/pdf
> 
> Well as I said netscape does it correctly.
> Any ideas about the ie?

Hmmm... There is a content-length in there.  Where is it coming from? 
Is it the correct content-length?

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: content length header in ExtFilterDefine

Posted by Werner Schalk <we...@gmx.de>.
Hello,

I'm sorry I posted the wrong options,
I did not use PreservesContentLength
here! Anyway I use 2.0.40 of course.

Apache seems to send the headers
correctly:

skywalk:/home/werner# lynx -head -dump http://localhost/test.html
HTTP/1.1 200 OK
Date: Fri, 23 Aug 2002 14:22:26 GMT
Server: Apache/2.0.40 (Unix)
Last-Modified: Thu, 22 Aug 2002 21:48:01 GMT
ETag: "23b3ab-1a2-e0126640"
Accept-Ranges: bytes
Content-Length: 2964
Connection: close
Content-Type: application/pdf

Well as I said netscape does it correctly.
Any ideas about the ie?

Bye and thanks,
Werner.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: content length header in ExtFilterDefine

Posted by Joshua Slive <jo...@slive.ca>.
Werner Schalk wrote:
> Hello,
> 
> well together with a friend I tried
> to write an output filter which converts
> text to pdf content. So I installed
> ghostscript and a2ps and wrote a small
> shell script which reads data from
> stdin, converts to pdf and prints
> this to stdout. It looks like this:
> /usr/local/a2ps-4.13/bin/a2ps -q -o - |
> /usr/local/ghostscript-7.05/bin/ps2pdfwr -
> 
> Then in httpd.conf I created this:
> ExtFilterDefine pdfwriter mode=output intype=text/html
> outtype=application/pdf PreservesContentLength

Wohhh!  What is "PreservesContentLength" doing in there.  This filter 
obviously changes the content length!

> And even later on:
> "...To resolve this behavior, contact the Web site author or
> administrator. Web site authors or administrators can resolve this
> problem if they configure their Web servers to send both a content-type
> header (MIME type) of "application/pdf" for .pdf files and an
> appropriate content-length header".
> 
> That why I thought of sending a content-length header to the client.

Ahh, OK, I didn't read that part carefully enough.  That is really bad 
behavior if it is true.  That would make it essentially impossible for 
cgi scripts to deliver PDF documents.  I'm guessing that this 
knowledgebase article is not perfectly accurate.

After fixing the PreservesContentLength issue, I'd start by looking at 
the actual HTTP headers that apache is sending with this file (using 
lynx -head -dump or a similar tool).

Depending on which version of Apache 2.0 you are running, you may also 
be hitting a bug with chunked encoding.  Make sure you are using 2.0.40.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: content length header in ExtFilterDefine

Posted by Werner Schalk <we...@gmx.de>.
Hello,

well together with a friend I tried
to write an output filter which converts
text to pdf content. So I installed
ghostscript and a2ps and wrote a small
shell script which reads data from
stdin, converts to pdf and prints
this to stdout. It looks like this:
/usr/local/a2ps-4.13/bin/a2ps -q -o - |
/usr/local/ghostscript-7.05/bin/ps2pdfwr -

Then in httpd.conf I created this:
ExtFilterDefine pdfwriter mode=output intype=text/html
outtype=application/pdf PreservesContentLength
cmd="/usr/local/apache2/bin/pdfwrite.sh"
<Files *.html>
    ExtFilterOptions LogStderr DebugLevel=9
    SetOutputFilter pdfwriter
</Files>

Now I start the apache and open an example
index.html with netscape and voila he shows
me the pdf. BUT the ie just prints an empty
page instead of showing the pdf. In the
knowledgebase article is written that
"This behavior occurs because the uniform resource identifier (URI) to
the .pdf file does not end in ".pdf" (for example, the file is opened
through script or the file is dynamically generated), and the
content-type header (Multipurpose Internet Mail Extensions [MIME] type)
that is returned by the server is "unknown/unknown" or no content-length
header was returned".

And even later on:
"...To resolve this behavior, contact the Web site author or
administrator. Web site authors or administrators can resolve this
problem if they configure their Web servers to send both a content-type
header (MIME type) of "application/pdf" for .pdf files and an
appropriate content-length header".

That why I thought of sending a content-length header to the client.

The error_log shows this:
[Thu Aug 22 23:48:14 2002] [debug] mod_ext_filter.c(605): [client
192.168.0.2] filtering `/bla.html' of type `application/pdf'
 through `/usr/local/apache2/bin/pdfwrite.sh', cfg ExtFilterOptions
DebugLevel=9 LogStderr PreservesContentLength ExtFilterInT
ype text/html ExtFilterOuttype application/pdf
[Thu Aug 22 23:48:15 2002] [debug] mod_ext_filter.c(802): [client
192.168.0.2] apr_file_read(child output), len 512
[Thu Aug 22 23:48:15 2002] [debug] mod_ext_filter.c(802): [client
192.168.0.2] apr_file_read(child output), len 442
[Thu Aug 22 23:48:15 2002] [debug] mod_ext_filter.c(802): [client
192.168.0.2] apr_file_read(child output), len 2012
[Thu Aug 22 23:48:15 2002] [debug] mod_ext_filter.c(802): [client
192.168.0.2] (20514)End of file found: apr_file_read(child output), len
-1

Is there a way to implement this cool output filter
anyhow?

Bye and thanks,
Werner.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: content length header in ExtFilterDefine

Posted by Joshua Slive <jo...@slive.ca>.
Werner Schalk wrote:
> Hello,
> 
> well as I said my filter works with
> netscape. I don't use PreservesContentLength
> because my filter modifies the size
> of the document. The problem I'm
> currently facing is described here:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q305153
> 
> Well of course it is a design problem within
> the ie but it would be great to
> have a feature to send a content
> length header...any ideas?

The knowledgebase article you reference has NOTHING to do with 
content-length.  Content-length is not required.  If it was, then 
practically no cgi script would work.

Please take another look at what is really going on and try to give us 
more accurate details.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: content length header in ExtFilterDefine

Posted by Werner Schalk <we...@gmx.de>.
Hello,

well as I said my filter works with
netscape. I don't use PreservesContentLength
because my filter modifies the size
of the document. The problem I'm
currently facing is described here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q305153

Well of course it is a design problem within
the ie but it would be great to
have a feature to send a content
length header...any ideas?

Bye and thanks,
Werner.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: content length header in ExtFilterDefine

Posted by Joshua Slive <jo...@slive.ca>.
On Thu, 22 Aug 2002, Werner Schalk wrote:

> Hello,
>
> is it possible to send an content length
> header before sending the output of
> an external filter to a client?

No, because the content-length cannot be known before the output is sent
(unless you want apache to queue up the whole response to count it --
ouch).

>
> How can I do this? If it is not possible,
> could such a feature be added to
> ExtFilterDefine please?
>
> I coded a filter which works fine
> for netscape but internet exploder wants this
> content length header to be set before
> showing the results of my filter :-(

There must be some other problem.  Content-Length should not be required.
Are you using PreservesContentLength?  If so, are you modifying the size
of the content with your filter?

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org