Search in sources :

Example 1 with HttpHeadersFilter

use of org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter in project spring-cloud-gateway by spring-cloud.

the class WebsocketRoutingFilter method getHeadersFilters.

private List<HttpHeadersFilter> getHeadersFilters() {
    List<HttpHeadersFilter> filters = this.headersFilters.getIfAvailable();
    if (filters == null) {
        filters = new ArrayList<>();
    }
    filters.add((headers, exchange) -> {
        HttpHeaders filtered = new HttpHeaders();
        headers.entrySet().stream().filter(entry -> !entry.getKey().toLowerCase().startsWith("sec-websocket")).forEach(header -> filtered.addAll(header.getKey(), header.getValue()));
        return filtered;
    });
    return filters;
}
Also used : HttpHeadersFilter.filterRequest(org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter.filterRequest) Ordered(org.springframework.core.Ordered) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ServerWebExchangeUtils.setAlreadyRouted(org.springframework.cloud.gateway.support.ServerWebExchangeUtils.setAlreadyRouted) Arrays(java.util.Arrays) WebSocketSession(org.springframework.web.reactive.socket.WebSocketSession) HttpHeadersFilter(org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter) WebSocketClient(org.springframework.web.reactive.socket.client.WebSocketClient) ArrayList(java.util.ArrayList) ServerWebExchange(org.springframework.web.server.ServerWebExchange) StringUtils.commaDelimitedListToStringArray(org.springframework.util.StringUtils.commaDelimitedListToStringArray) ObjectProvider(org.springframework.beans.factory.ObjectProvider) WebSocketHandler(org.springframework.web.reactive.socket.WebSocketHandler) URI(java.net.URI) HttpHeaders(org.springframework.http.HttpHeaders) Mono(reactor.core.publisher.Mono) WebSocketService(org.springframework.web.reactive.socket.server.WebSocketService) Collectors(java.util.stream.Collectors) List(java.util.List) GATEWAY_REQUEST_URL_ATTR(org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR) WebSocketMessage(org.springframework.web.reactive.socket.WebSocketMessage) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) ServerWebExchangeUtils.isAlreadyRouted(org.springframework.cloud.gateway.support.ServerWebExchangeUtils.isAlreadyRouted) Collections(java.util.Collections) HttpHeaders(org.springframework.http.HttpHeaders) HttpHeadersFilter(org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter)

Aggregations

URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 ObjectProvider (org.springframework.beans.factory.ObjectProvider)1 HttpHeadersFilter (org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter)1 HttpHeadersFilter.filterRequest (org.springframework.cloud.gateway.filter.headers.HttpHeadersFilter.filterRequest)1 GATEWAY_REQUEST_URL_ATTR (org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR)1 ServerWebExchangeUtils.isAlreadyRouted (org.springframework.cloud.gateway.support.ServerWebExchangeUtils.isAlreadyRouted)1 ServerWebExchangeUtils.setAlreadyRouted (org.springframework.cloud.gateway.support.ServerWebExchangeUtils.setAlreadyRouted)1 Ordered (org.springframework.core.Ordered)1 HttpHeaders (org.springframework.http.HttpHeaders)1 StringUtils.commaDelimitedListToStringArray (org.springframework.util.StringUtils.commaDelimitedListToStringArray)1 WebSocketHandler (org.springframework.web.reactive.socket.WebSocketHandler)1 WebSocketMessage (org.springframework.web.reactive.socket.WebSocketMessage)1 WebSocketSession (org.springframework.web.reactive.socket.WebSocketSession)1