HTTP Response Header Manipulate
The HTTP header manipulation feature allows you to fine-tune incoming and outgoing request and response headers.
In Gateway API, the HTTPRoute resource utilities two HTTPHeaderFilter
filter for request and response header manipulation.
The both filters supports add
, set
and remove
operation. The combination of them is also available.
This document will introduce the HTTP response header manipulation function of FSM Gateway. The introduction of HTTP request header manipulation is located in doc HTTP Request Header Manipulate.
Prerequisites
- Kubernetes cluster version v1.21.0 or higher.
- kubectl CLI
- FSM Gateway installed via guide doc.
Demonstration
We will follow the sample in HTTP Routing.
In backend service responds the generated headers as below.=
Add HTTP Response header
With header adding feature, let’s try to add a new header to response by add HTTPHeaderFilter
filter.
Modifying the HTTPRoute
http-route-foo
and add ResponseHeaderModifier
filter.
Now request the path /headers
again and you will get the new header in response injected by gateway.
Set HTTP Response header
set
operation is used to update the value of specified header. If the header not exist, it will do as add
operation.
Let’s update the HTTPRoute
resource again and set two headers with new value. One does not exist and another does.
In the response, we can get the two headers updated.
Remove HTTP Response header
The last operation is remove
, which can remove the header of client sending.
Let’s update the HTTPRoute
resource to remove server
header directly to hide backend implementation from client.
With resource udpated, the backend server implementation is invisible on client side.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.