|
1 | 1 | package io.github.kimmking.gateway.outbound.httpclient4; |
2 | 2 |
|
3 | 3 |
|
| 4 | +import io.github.kimmking.gateway.filter.HeaderHttpResponseFilter; |
4 | 5 | import io.github.kimmking.gateway.filter.HttpRequestFilter; |
| 6 | +import io.github.kimmking.gateway.filter.HttpResponseFilter; |
5 | 7 | import io.github.kimmking.gateway.router.HttpEndpointRouter; |
6 | 8 | import io.github.kimmking.gateway.router.RandomHttpEndpointRouter; |
7 | 9 | import io.netty.buffer.Unpooled; |
@@ -36,6 +38,7 @@ public class HttpOutboundHandler { |
36 | 38 | private ExecutorService proxyService; |
37 | 39 | private List<String> backendUrls; |
38 | 40 |
|
| 41 | + HttpResponseFilter filter = new HeaderHttpResponseFilter(); |
39 | 42 | HttpEndpointRouter router = new RandomHttpEndpointRouter(); |
40 | 43 |
|
41 | 44 | public HttpOutboundHandler(List<String> backends) { |
@@ -121,9 +124,12 @@ private void handleResponse(final FullHttpRequest fullRequest, final ChannelHand |
121 | 124 | // System.out.println(body.length); |
122 | 125 |
|
123 | 126 | response = new DefaultFullHttpResponse(HTTP_1_1, OK, Unpooled.wrappedBuffer(body)); |
| 127 | + |
124 | 128 | response.headers().set("Content-Type", "application/json"); |
125 | 129 | response.headers().setInt("Content-Length", Integer.parseInt(endpointResponse.getFirstHeader("Content-Length").getValue())); |
126 | | - |
| 130 | + |
| 131 | + filter.filter(response); |
| 132 | + |
127 | 133 | // for (Header e : endpointResponse.getAllHeaders()) { |
128 | 134 | // //response.headers().set(e.getName(),e.getValue()); |
129 | 135 | // System.out.println(e.getName() + " => " + e.getValue()); |
|
0 commit comments