Removing the charset=UTF-8 in Content-type

Hei everyone. i got a question.

how to remove the charset=UTF-8 in the Content-type in Response Headers?
it was an image file and i want the Content-type value to be just image/png. but instead, it has charset=UTF-8 value as well. i want to remove this because i suspect this is the cause of my caching problem. sorry for my bad english. if there are any expert that can help me, it would be very much appreciated!

thank you!

In an hst component you can set content type on the hstResponse object

can you point out the path or if possible, the YAML import command? i don’t see the hstResponse inside the hst:component and i cannot set it as well. did i miss something?

thanks for the reply!

when you say content-type in response headers, which request are you talking about ? /binaries/… ?

yes in /binaries/…

thanks for the reply!

After some debugging I found that this charset=UTF-8 is added by tomcat. Couldn’t find where the config for this is however. You can set a breakpoint at org.hippoecm.hst.servlet.BinariesServlet#writeResponse method’s “response.setContentType(pageMimeType);” line and observe the response.getContentType header to verify.

1 Like

It turns out this is actually characterencodingfilter. Check out this stackoverflow thread

1 Like

alright! thank you so much for your help! i will try and see what i can do. i will reach to you again if i am stuck. thank you so much for your help!

1 Like

hello again!

i have tried all the suggestion that the tread mentioned. it didn’t remove the charset in content type, even after i modify the characterencodingfilter. Did i miss something or am i configuring it wrongly? can you guide me on how and where should i modify this param?

thank you in advance!

Hey @kaef, I just did a quick test by changing the init param like the following:


notice that forceEncoding is false. This worked for me i dont get the charset appended. Can you try it in an incognito browser as well?

1 Like

i change it. it works! no more charset in the headers.

Thank you!

You realize that you are potentially screwing up any user submitted data by doing so? (so, if you are using forms submitting, any none ascii characters will be processed by whatever character set your sever is configured)

yes i do realize, i want to do this so i can troubleshoot my caching problem, i suspect this charset inside content-type was the one causing it. thank you for your concern btw!