from config.config import SystemConfig
from django.utils.deprecation import MiddlewareMixin  # 1.10.x


class HttpResponseCustomHeader(MiddlewareMixin):

    def process_response(self, request, response):
        # if not response.has_header("product")
        #     response["product"] = '{} {}'.format(settings.SOFTWARENAME,
        #                                          settings.VERSION)
        # if not response.has_header("X-Powered-By"):

        # 添加自定义 X-Powered-By 头
        response["X-Powered-By"] = '{} {}'.format(SystemConfig.SOFTWARENAME,
                                                  SystemConfig.VERSION.replace('_','.'))
        # 添加自定义 X-Company-Website 头
        response['X-Company-Website'] = 'http://www.djacore.com'
        return response
