This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: mod_headers question: content-type
Author
Message |
4sfed
Newbie


Joined: 05 July 2010
Posts: 4
Posted: 05 July 2010 at 12:10am

Hi guys,

i am having an issue trying to configure the mod_headers
module in APE. I am running Win 2008/iis7.

The issue i am having is that certain pages in our
application are getting created with an invalid content-
type. it is being generated like this:

Content-Type     ;charset=utf-8

As you can see its missing the text/html (or whatever the
page is).

I have tried to use APE to fix this for me and am getting
some level of success but its not perfect.

Because there are only 1 or 2 pages in our entire app
that is having this issue, i want to edit any content-
type header that ONLY contains ";charset=utf-8" and
ignore anything that has a complete content type.

I tried this rule:

Header edit Content-Type ;charset=utf-8
text/html;charset=utf-8

But it actually replaces the ;charset=utf-8 on in every
header even when it is complete, so i end up with a
content type that looks like this:

Content-Type     text/htmltext/html;charset=utf-8

This causes all sorts of problems.

I have also tried this to just force every page to have a
predefined content-type but this breaks xml pages:

Header set Content-Type "text/html;charset=utf-8"

So my question is this. Is there any way that i can
configure it so that if the content-type contains ONLY
;charset=utf-8, then modify it. But if it contains a
correct content type (ie: anything infront of the
;charset=utf-8) then ignore it?

Thanks in advance.

Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 05 July 2010 at 2:23am

Hello,
You were close with ‘Header edit’ directive. See, the thing after header name is a regular expression. If those wrong headers come with ‘;charset=utf-8’ value only you should use something as follows:
Code:
Header edit Content-Type ^\s*;charset=utf-8\s*$ "text/html; charset=utf-8"


__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
4sfed
Newbie


Joined: 05 July 2010
Posts: 4
Posted: 06 July 2010 at 1:01am

Wow you are a genius! That code seems to work perfectly. I
will do some additional testing but i think that may have
it fixed. I will let you know.

Thanks so much!
Back to Top
 
4sfed
Newbie


Joined: 05 July 2010
Posts: 4
Posted: 06 July 2010 at 7:43pm

I have an additional question on this, will the code you
provided work for the apache mod_headers module or is this
specific to APE?

I am just trying to investigate the possibility of using
this same logic in Apache. The issue i am faced with is
that the system in question is currently deployed on
windows 2003 and this functionality in APE only works in
windows 2008. It would be much easier for me to change to
apache on windows 2003 than to rebuild them as 2008 and
iis7.
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 07 July 2010 at 12:55am

Hello,
I wasn’t able to get exactly Content-Type header modified, but with a test header it worked on Apache:
Code:
Header set TEST ";charset=utf-8"
Header edit TEST ^\s*;charset=utf-8\s*$ "text/html; charset=utf-8"


__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
4sfed
Newbie


Joined: 05 July 2010
Posts: 4
Posted: 07 July 2010 at 5:02pm

Thanks! That seemed to be the exact same issue that i was
seeing. I was able to set a new header but i was not able
to modify the existing content-type header.
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 08 July 2010 at 5:33am

Hello,
Well Apache and IIS are different server so mod_headers of Helicon Ape may have some differences in its behaviour. Perhaps in Apache you can’t change Content-Type like that.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version