|
28 | 28 | import java.util.*; |
29 | 29 |
|
30 | 30 | import static io.vertx.core.http.HttpHeaders.CONNECTION; |
| 31 | +import static io.vertx.core.http.HttpHeaders.HOST; |
31 | 32 | import static io.vertx.core.http.HttpHeaders.UPGRADE; |
32 | 33 |
|
33 | 34 | public class ReverseProxy implements HttpProxy { |
@@ -175,11 +176,18 @@ public Future<ProxyResponse> sendRequest() { |
175 | 176 | return resolveOrigin(this).compose(request -> { |
176 | 177 | request.setMethod(request().getMethod()); |
177 | 178 | request.setURI(request().getURI()); |
178 | | - // Firefox is known to send an unexpected connection header value |
179 | | - // Connection=keep-alive, Upgrade |
180 | | - // It leads to a failure in websocket proxying |
181 | | - // So we make sure the standard value is sent to the backend |
182 | | - request.headers().addAll(request().headers()).set(CONNECTION, UPGRADE); |
| 179 | + for (Map.Entry<String, String> header : request().headers()) { |
| 180 | + String name = header.getKey(); |
| 181 | + if (name.equalsIgnoreCase(CONNECTION.toString())) { |
| 182 | + // Firefox is known to send an unexpected connection header value |
| 183 | + // Connection=keep-alive, Upgrade |
| 184 | + // It leads to a failure in websocket proxying |
| 185 | + // So we make sure the standard value is sent to the backend |
| 186 | + request.headers().set(CONNECTION, UPGRADE); |
| 187 | + } else if (!name.equalsIgnoreCase(HOST.toString())) { |
| 188 | + request.headers().add(name, header.getValue()); |
| 189 | + } |
| 190 | + } |
183 | 191 | Future<HttpClientResponse> responseFuture = request.connect(); |
184 | 192 | ReadStream<Buffer> readStream = request().getBody().stream(); |
185 | 193 | readStream.handler(request::write); |
|
0 commit comments