Removing headers sent

#1
Hello!

for some reason, there is multiple response headers in my responses.
  1. Content-Length:
    306189
  2. Content-Length:
    306189
  3. Content-Type:
    application/json;charset=utf-8
  4. Content-Type:
    application/octet-stream

Is anyone of these sent by OLS, and if so, how do i remove them? :S
 

lsfoo

Moderator
#3
Hi Enthess,

We do not believe that OLS is the root cause of this problem. Can you provide the steps/pages accessed to reproduce the issue?

Kevin
 
#4
Hi @lsfoo,
There's no way for you to try this out sadly,
We have identified some duplicate headers in one server and removed them. But then some questions are unanswered... Who sends what? :D

HTTP/1.1 200 OK <--- from the PHP framework
X-Powered-By: PHP/7.0.9 <--- from PHP (expose_php)
Content-Type: application/json;charset=utf-8 <--- from PHP framework
Expires: Wed, 07 Sep 2016 09:40:09 GMT <--- from PHP framework
Cache-Control: public, max-age=120 <--- from PHP framework
Content-Length: 314661 <--- from PHP framework
Date: Wed, 07 Sep 2016 06:40:09 GMT <--- from who??
Connection: Keep-Alive <--- from OLS


and how i accessed, by curl.
curl -s -D - -X GET -H "Content-Type: application/json" http://localhost/api/ -o /dev/null | less :)
 

lsfoo

Moderator
#5
Date, Connection, and possibly Expires will be set by OLS. Not sure about much else, but I can always ask the relevant dev if you have any specific q's :)
 
#6
Expires is at the moment set by the framework, i know it can be added to OLS, but currently its not.
However, i cant remove the "date"-header, and my question is simply why ?

At the moment, we have fixed all the duplicate headers, everything is fine. But i like OLS and i want to know how to modify which headers are being sent... :)
 

lsfoo

Moderator
#7
Hi Enthess,

There is no direct way to modify response headers, unfortunately.

When it comes to the Date header specifically, that is added at the very end, so that specific header is not modifiable.

That said, we have a module system in beta in OLS. What this does is it allows you to hook into the server's processing loop to modify the processing as you wish. This is accomplished in C code.

We have an example module in the downloaded directory here: ols-1.4.23/addon/example/setrespheader.c
That module sets headers according to the query string. There is also an example of removing response headers in that file.

If you're interested in proceeding further with modules, try this one out first. You will need to:
1. In that directory, run ./ccc.sh setrespheader.c
2. Move the .so to the server's module directory mv setrespheader.so /usr/local/lsws/modules
3. Enable the module in the configurations per instructions here. (I know that web admin is outdated, but the instructions should be similar)

Let me know if you have any questions about this! I understand that it's a rather complex process to do what seems like a simple thing, but header modification is just not available at the moment. Perhaps in the future it will be made available, but it will probably be a while.

Cheers,
Kevin
 
#8
hi @lsfoo !

I understand ! Its nice that you found where that header was set!

The solution is rather complex and the Date-header is not a problem at all!
I just wanted to understand why it wasnt "removable" since alot other headers are!

Since we noticed the other multiple headers sent, they have been removed, now is only OLS and PHP Framework-headers, and they are OK! :)
 
Top