@Override
	public HttpHeaders filter(HttpHeaders headers, ServerWebExchange exchange) {
		HttpHeaders updated = new HttpHeaders();

		for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
			updated.addAll(entry.getKey(), entry.getValue());
		}

		// https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.2
		if (isGRPC(headers.getFirst(HttpHeaders.CONTENT_TYPE))) {
			updated.add("te", "trailers");
		}
		return updated;
	}
@Test
	public void shouldIncludeTrailersHeaderIfGRPC() {
		MockServerHttpRequest request = MockServerHttpRequest.get("http://localhost:8080/get")
			.header(HttpHeaders.CONTENT_TYPE, "application/grpc")
			.build();

		GRPCRequestHeadersFilter filter = new GRPCRequestHeadersFilter();

		HttpHeaders headers = filter.filter(request.getHeaders(), MockServerWebExchange.from(request));

		assertThat(headers).containsKeys("te");

		assertThat(headers.getFirst("te")).isEqualTo("trailers");
	}