Updated on 2022-12-05 GMT+08:00

HTTP Response Header Management Plug-in

Overview

An HTTP response header is a part of an API response. An HTTP response header management plug-in enables you to customize HTTP response headers that will be returned in an API response.

Restrictions

  • The system response headers (such as x-apig-* and x-request-id) cannot be modified.
  • The response headers for CORS cannot be modified.

Parameter Description

Table 1 Configuration parameters

Parameter

Description

Name

Response header name, which is case-insensitive and must be unique within a plug-in.

Value

Value of the response header. This parameter does not take effect and can be left blank if you set Action to Delete.

Action

Response header operation. You can override, append, delete, skip, or add the specified header.

  • Override
    • The value of this response header will override that of the same header that exists in an API response.
    • If an API response contains multiple response headers with the same name, only the value of this response header will be returned.
    • If there is no response header with the same name in an API response, the value of this response header will be returned.
  • Append
    • If an API response contains the specified header, the value you set here will be added, following the existing value. The two values will be separated with commas (,).
    • If an API response contains multiple headers with the same name as the one you set here, values of these headers will be separated with commas (,) and followed by the value of the specified header.
    • If there is no response header with the same name in an API response, the value of this response header will be returned.
  • Delete
    • This response header will be deleted if a response header with the same name exists in an API response.
    • If an API response contains multiple response headers with the same name, all these response headers will be deleted.
  • Skip
    • If an API response contains the specified header, the header will be skipped.
    • If an API response contains multiple headers with the same name as the one you set here, values of all these headers will be returned without modification.
    • If there is no response header with the same name in an API response, the value of this response header will be returned.
  • Add

    The value of the specified header will be returned even if the header does not exist in an API response.

Script Configuration Example

{
  "response_headers": [
    {
      "name": "header1",
      "value": "test",
      "action": "append"
    },
    {
      "name": "header2",
      "value": "roma",
      "action": "override"
    }
  ]
}