You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by b k <bk...@gmail.com> on 2009/11/03 20:20:27 UTC

[users@httpd] pdf report generation - content type text/html

Hi all,
PDF reports are not being generated on any browser. On IE, I get the File
Save dialog and on Firefox, all weird characters get displayed. When I ran
this test again with HTTPFox and Fiddler, I noticed that the content-type in
the response header is *text/html* for this PDF report, which is definitely
causing the problem. I am using apache 2.2.3 with mod security turned on/off
(doesn't matter). Any help would be greatly appreciated!!!!

Re: [users@httpd] pdf report generation - content type text/html

Posted by b k <bk...@gmail.com>.
thanks for ur input. But, as I said before, the reports work directly on the
app server. However, the report fails to open if you provide a smaller date
range (period) and works fine with a bigger date range. Is there any setting
on web server that I need to check for min/max response data size or
something like that. pls let me know.

On Mon, Nov 16, 2009 at 3:13 PM, Philip Wigg <ph...@philipwigg.co.uk> wrote:

> > I tried all possibilities but no luck yet. I just realized this morning
> that
> > the OS patch level on Test and Prod servers are different. Test reports
> are
> > working but not the Prod, may be due to fact that Test servers have
> LATEST
> > PATCH LEVEL??? Is it possible??? Please let me know.
>
> It's quite possibly due to some differences in the application server
> configuration, you're probably best asking IBM. Possibly it's
> something like this:-
>
>
> http://www-01.ibm.com/support/docview.wss?rs=2169&context=SS5K3U&dc=DB550&q1=JR30578&uid=swg1JR30578&loc=en_US&cs=utf-8&lang=en
>
> It doesn't sound like the problem is due to Apache though.
>
> ---------------------------------------------------------------------
> 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: [users@httpd] pdf report generation - content type text/html

Posted by Philip Wigg <ph...@philipwigg.co.uk>.
> I tried all possibilities but no luck yet. I just realized this morning that
> the OS patch level on Test and Prod servers are different. Test reports are
> working but not the Prod, may be due to fact that Test servers have LATEST
> PATCH LEVEL??? Is it possible??? Please let me know.

It's quite possibly due to some differences in the application server
configuration, you're probably best asking IBM. Possibly it's
something like this:-

http://www-01.ibm.com/support/docview.wss?rs=2169&context=SS5K3U&dc=DB550&q1=JR30578&uid=swg1JR30578&loc=en_US&cs=utf-8&lang=en

It doesn't sound like the problem is due to Apache though.

---------------------------------------------------------------------
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: [users@httpd] pdf report generation - content type text/html

Posted by b k <bk...@gmail.com>.
I tried all possibilities but no luck yet. I just realized this morning that
the OS patch level on Test and Prod servers are different. Test reports are
working but not the Prod, may be due to fact that Test servers have LATEST
PATCH LEVEL??? Is it possible??? Please let me know.

On Tue, Nov 3, 2009 at 3:43 PM, Brian Mearns <me...@gmail.com> wrote:

> On Tue, Nov 3, 2009 at 3:06 PM, b k <bk...@gmail.com> wrote:
> > Thanks!! Actually, it's a java based app on the WebSphere app server that
> > sends the response to Apache web server which in turn sends the response
> to
> > the browser. I tested the reports directly on the App server which are
> > working fine. I suspect something is wrong in the apache config. I also
> > checked mime.types file which includes pdf entry.
> >
> > On Tue, Nov 3, 2009 at 2:32 PM, Brian Mearns <me...@gmail.com> wrote:
> >>
> >> On Tue, Nov 3, 2009 at 2:26 PM, Marcin 'Rambo' Roguski
> >> <ra...@id.uw.edu.pl> wrote:
> >> > On Tue, 3 Nov 2009 14:20:27 -0500
> >> > b k <bk...@gmail.com> wrote:
> >> >
> >> >> Hi all,
> >> >> PDF reports are not being generated on any browser. [...]Any help
> would
> >> >> be greatly
> >> >> appreciated!!!!
> >> >
> >> > Send Content-Type: application/pdf or application/octet-stream from
> your
> >> > PDF generator
> >> > text/html is just plain wrong.
> >> >
> >> > --
> >> > Maslow's Maxim:
> >> >        If the only tool you have is a hammer, you treat everything
> like
> >> >        a nail.
> >> >
> >>
> >> Well what's generating the PDF's? If they're coming from a file, you
> >> need to configure Apache to correctly detect the mime type (as with
> >> mod_mime: http://httpd.apache.org/docs/2.2/mod/mod_mime.html). Or if
> >> they're all accessed through a particular root URL (like
> >> /reports/pdf/), you can use the <Location> tag and ForceType:
> >> http://httpd.apache.org/docs/2.2/mod/core.html#forcetype.
> >>
> >> If it's being generated by a server side script, you can try the above
> >> <Location> method, or better, just get your script to generate the
> >> correct Content-Type header. If you're using PHP, the default mime
> >> type if you don't say otherwise is usually text/html, as you found,
> >> but you can use the header() function to send the CT header like:
> >> header("Content-Type: application/pdf").
> >>
> >> -Brian
> >>
> >> --
> >> Feel free to contact me using PGP Encryption:
> >> Key Id: 0x3AA70848
> >> Available from: http://keys.gnupg.net
>
> It sounds like you're saying you get the correct content-type header
> if you communicate directly with the app server, and that Apache is
> blowing it away? That's quite odd, but you might still try the
> <Location> tag or similar to match the URL's the reports are accessed
> by, and then use ForceType. I'm not sure if Apache will replace an
> existing Content-Type header in this case, but it's worth a try.
>
> -Brian
>
>
> --
> Feel free to contact me using PGP Encryption:
> Key Id: 0x3AA70848
> Available from: http://keys.gnupg.net
>
> ---------------------------------------------------------------------
> 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: [users@httpd] pdf report generation - content type text/html

Posted by Brian Mearns <me...@gmail.com>.
On Tue, Nov 3, 2009 at 3:06 PM, b k <bk...@gmail.com> wrote:
> Thanks!! Actually, it's a java based app on the WebSphere app server that
> sends the response to Apache web server which in turn sends the response to
> the browser. I tested the reports directly on the App server which are
> working fine. I suspect something is wrong in the apache config. I also
> checked mime.types file which includes pdf entry.
>
> On Tue, Nov 3, 2009 at 2:32 PM, Brian Mearns <me...@gmail.com> wrote:
>>
>> On Tue, Nov 3, 2009 at 2:26 PM, Marcin 'Rambo' Roguski
>> <ra...@id.uw.edu.pl> wrote:
>> > On Tue, 3 Nov 2009 14:20:27 -0500
>> > b k <bk...@gmail.com> wrote:
>> >
>> >> Hi all,
>> >> PDF reports are not being generated on any browser. [...]Any help would
>> >> be greatly
>> >> appreciated!!!!
>> >
>> > Send Content-Type: application/pdf or application/octet-stream from your
>> > PDF generator
>> > text/html is just plain wrong.
>> >
>> > --
>> > Maslow's Maxim:
>> >        If the only tool you have is a hammer, you treat everything like
>> >        a nail.
>> >
>>
>> Well what's generating the PDF's? If they're coming from a file, you
>> need to configure Apache to correctly detect the mime type (as with
>> mod_mime: http://httpd.apache.org/docs/2.2/mod/mod_mime.html). Or if
>> they're all accessed through a particular root URL (like
>> /reports/pdf/), you can use the <Location> tag and ForceType:
>> http://httpd.apache.org/docs/2.2/mod/core.html#forcetype.
>>
>> If it's being generated by a server side script, you can try the above
>> <Location> method, or better, just get your script to generate the
>> correct Content-Type header. If you're using PHP, the default mime
>> type if you don't say otherwise is usually text/html, as you found,
>> but you can use the header() function to send the CT header like:
>> header("Content-Type: application/pdf").
>>
>> -Brian
>>
>> --
>> Feel free to contact me using PGP Encryption:
>> Key Id: 0x3AA70848
>> Available from: http://keys.gnupg.net

It sounds like you're saying you get the correct content-type header
if you communicate directly with the app server, and that Apache is
blowing it away? That's quite odd, but you might still try the
<Location> tag or similar to match the URL's the reports are accessed
by, and then use ForceType. I'm not sure if Apache will replace an
existing Content-Type header in this case, but it's worth a try.

-Brian


-- 
Feel free to contact me using PGP Encryption:
Key Id: 0x3AA70848
Available from: http://keys.gnupg.net

---------------------------------------------------------------------
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: [users@httpd] pdf report generation - content type text/html

Posted by André Warnier <aw...@ice-sa.com>.
b k wrote:
> Thanks!! Actually, it's a java based app on the WebSphere app server that
> sends the response to Apache web server which in turn sends the response to
> the browser. I tested the reports directly on the App server which are
> working fine. I suspect something is wrong in the apache config. I also
> checked mime.types file which includes pdf entry.

Apache will only generate itself the "Content-Type" and 
"Content-Disposition" response headers, if the file being served is a 
file that Apache itself picks up from the filesystem.  That is also when 
it uses the mime.types file (to try and guess the type).

When it is an application which generates this data (or file), then it 
is the responsibility of the application to add these 2 headers to the 
response (at least the Content-Type).
When Apache sees a response about to go out, without a Content-Type 
header, it will add one of it's own, but that is a default set in the 
configuration, usually set to
Content-Type: text/html
(because that is the most likely on a webserver)

So, whatever your application is, it is probably not producing this or 
these HTTP headers, which is why Apache adds its own default 'text/html' 
header, and that is the reason for the problem.

To my knowledge, there is nothing in Apache that will remove a 
Content-Type header set by an application and replace it by another one, 
unless you have specifically configured it to do that.

There are additional miseries in this due to the inconsistency of IE 
versions in interpreting the content coming from a webserver, but I 
believe that would be a second step, and you need to resolve the one 
above first.

---------------------------------------------------------------------
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: [users@httpd] pdf report generation - content type text/html

Posted by b k <bk...@gmail.com>.
Thanks!! Actually, it's a java based app on the WebSphere app server that
sends the response to Apache web server which in turn sends the response to
the browser. I tested the reports directly on the App server which are
working fine. I suspect something is wrong in the apache config. I also
checked mime.types file which includes pdf entry.

On Tue, Nov 3, 2009 at 2:32 PM, Brian Mearns <me...@gmail.com> wrote:

> On Tue, Nov 3, 2009 at 2:26 PM, Marcin 'Rambo' Roguski
> <ra...@id.uw.edu.pl> wrote:
> > On Tue, 3 Nov 2009 14:20:27 -0500
> > b k <bk...@gmail.com> wrote:
> >
> >> Hi all,
> >> PDF reports are not being generated on any browser. [...]Any help would
> be greatly
> >> appreciated!!!!
> >
> > Send Content-Type: application/pdf or application/octet-stream from your
> PDF generator
> > text/html is just plain wrong.
> >
> > --
> > Maslow's Maxim:
> >        If the only tool you have is a hammer, you treat everything like
> >        a nail.
> >
>
> Well what's generating the PDF's? If they're coming from a file, you
> need to configure Apache to correctly detect the mime type (as with
> mod_mime: http://httpd.apache.org/docs/2.2/mod/mod_mime.html). Or if
> they're all accessed through a particular root URL (like
> /reports/pdf/), you can use the <Location> tag and ForceType:
> http://httpd.apache.org/docs/2.2/mod/core.html#forcetype.
>
> If it's being generated by a server side script, you can try the above
> <Location> method, or better, just get your script to generate the
> correct Content-Type header. If you're using PHP, the default mime
> type if you don't say otherwise is usually text/html, as you found,
> but you can use the header() function to send the CT header like:
> header("Content-Type: application/pdf").
>
> -Brian
>
> --
> Feel free to contact me using PGP Encryption:
> Key Id: 0x3AA70848
> Available from: http://keys.gnupg.net
>
> ---------------------------------------------------------------------
> 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: [users@httpd] pdf report generation - content type text/html

Posted by Brian Mearns <me...@gmail.com>.
On Tue, Nov 3, 2009 at 2:26 PM, Marcin 'Rambo' Roguski
<ra...@id.uw.edu.pl> wrote:
> On Tue, 3 Nov 2009 14:20:27 -0500
> b k <bk...@gmail.com> wrote:
>
>> Hi all,
>> PDF reports are not being generated on any browser. [...]Any help would be greatly
>> appreciated!!!!
>
> Send Content-Type: application/pdf or application/octet-stream from your PDF generator
> text/html is just plain wrong.
>
> --
> Maslow's Maxim:
>        If the only tool you have is a hammer, you treat everything like
>        a nail.
>

Well what's generating the PDF's? If they're coming from a file, you
need to configure Apache to correctly detect the mime type (as with
mod_mime: http://httpd.apache.org/docs/2.2/mod/mod_mime.html). Or if
they're all accessed through a particular root URL (like
/reports/pdf/), you can use the <Location> tag and ForceType:
http://httpd.apache.org/docs/2.2/mod/core.html#forcetype.

If it's being generated by a server side script, you can try the above
<Location> method, or better, just get your script to generate the
correct Content-Type header. If you're using PHP, the default mime
type if you don't say otherwise is usually text/html, as you found,
but you can use the header() function to send the CT header like:
header("Content-Type: application/pdf").

-Brian

-- 
Feel free to contact me using PGP Encryption:
Key Id: 0x3AA70848
Available from: http://keys.gnupg.net

---------------------------------------------------------------------
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: [users@httpd] pdf report generation - content type text/html

Posted by Marcin 'Rambo' Roguski <ra...@id.uw.edu.pl>.
On Tue, 3 Nov 2009 14:20:27 -0500
b k <bk...@gmail.com> wrote:

> Hi all,
> PDF reports are not being generated on any browser. [...]Any help would be greatly
> appreciated!!!!

Send Content-Type: application/pdf or application/octet-stream from your PDF generator
text/html is just plain wrong.

-- 
Maslow's Maxim:
	If the only tool you have is a hammer, you treat everything like 
	a nail.

---------------------------------------------------------------------
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