from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from bclib.context import RequestContext


class HttpHeaders:
    ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"
    ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"
    ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods"
    ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"
    ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers"
    ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age"
    ACCEPT_RANGES = "Accept-Ranges"
    AGE = "Age"
    ALLOW = "Allow"
    ALTERNATE_PROTOCOL = "Alternate-Protocol"
    CACHE_CONTROL = "Cache-Control"
    CLIENT_DATE = "Client-Date"
    CLIENT_PEER = "Client-Peer"
    CLIENT_RESPONSE_NUM = "Client-Response-Num"
    CONNECTION = "Connection"
    CONTENT_DISPOSITION = "Content-Disposition"
    CONTENT_ENCODING = "Content-Encoding"
    CONTENT_LANGUAGE = "Content-Language"
    CONTENT_LENGTH = "Content-Length"
    CONTENT_LOCATION = "Content-Location"
    CONTENT_MD5 = "Content-MD5"
    CONTENT_RANGE = "Content-Range"
    CONTENT_SECURITY_POLICY = "Content-Security-Policy"
    X_CONTENT_SECURITY_POLICY = "X-Content-Security-Policy"
    X_WEBKIT_CSP = "X-WebKit-CSP"
    CONTENT_SECURITY_POLICY_REPORT_ONLY = "Content-Security-Policy-Report-Only"
    CONTENT_TYPE = "Content-Type"
    DATE = "Date"
    ETAG = "ETag"
    EXPIRES = "Expires"
    HTTP = "HTTP"
    KEEP_ALIVE = "Keep-Alive"
    LAST_MODIFIED = "Last-Modified"
    LINK = "Link"
    LOCATION = "Location"
    P3P = "P3P"
    PRAGMA = "Pragma"
    PROXY_AUTHENTICATE = "Proxy-Authenticate"
    PROXY_CONNECTION = "Proxy-Connection"
    REFRESH = "Refresh"
    RETRY_AFTER = "Retry-After"
    SERVER = "Server"
    SET_COOKIE = "Set-Cookie"
    STATUS = "Status"
    STRICT_TRANSPORT_SECURITY = "Strict-Transport-Security"
    TIMING_ALLOW_ORIGIN = "Timing-Allow-Origin"
    TRAILER = "Trailer"
    TRANSFER_ENCODING = "Transfer-Encoding"
    UPGRADE = "Upgrade"
    VARY = "Vary"
    VIA = "Via"
    WARNING = "Warning"
    WWW_AUTHENTICATE = "WWW-Authenticate"
    X_ASPNET_VERSION = "X-Aspnet-Version"
    X_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options"
    X_FRAME_OPTIONS = "X-Frame-Options"
    X_PERMITTED_CROSS_DOMAIN_POLICIES = "X-Permitted-Cross-Domain-Policies"
    X_PINGBACK = "X-Pingback"
    X_POWERED_BY = "X-Powered-By"
    X_ROBOTS_TAG = "X-Robots-Tag"
    X_UA_COMPATIBLE = "X-UA-Compatible"
    X_XSS_PROTECTION = "X-XSS-Protection"

    @staticmethod
    def add_cors_headers(context: 'RequestContext'):
        context.add_header(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "*")
        context.add_header(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
                           "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With")
