@@ -316,7 +316,7 @@ Server support is organized in two layers:
316
316
317
317
* <<webflux-httphandler,HttpHandler>> and server adapters -- the most basic, common API
318
318
for HTTP request handling with Reactive Streams back pressure.
319
- * <<webflux-web-handler-api,WebHandler API >> -- slightly higher level but still general
319
+ * <<webflux-web-handler-api>> -- slightly higher level but still general
320
320
purpose server web API with filter chain style processing.
321
321
322
322
@@ -448,7 +448,7 @@ This can be automated through the use of
448
448
449
449
450
450
[[webflux-web-handler-api]]
451
- === WebHandler API
451
+ === WebHandler
452
452
453
453
`HttpHandler` is the lowest level contract for running on different HTTP servers.
454
454
On top of that foundation, the WebHandler API provides a slightly higher level, but
@@ -564,7 +564,7 @@ content to `Flux<Part>` without collecting to a `MultiValueMap`.
564
564
565
565
566
566
[[webflux-codecs]]
567
- === HTTP Message Codecs
567
+ === Message Codecs
568
568
[.small]#<<integration.adoc#rest-message-conversion,Same in Spring MVC>>#
569
569
570
570
The `spring-web` module defines the
@@ -641,6 +641,55 @@ a heartbeat and ignore.
641
641
642
642
643
643
644
+ [[webflux-filters]]
645
+ === Filters
646
+ [.small]#<<web.adoc#filters,Same in Spring MVC>>#
647
+
648
+ As part of the <<webflux-web-handler-api>>, the `spring-web` module provides a number of
649
+ `WebFilter` implementations.
650
+
651
+
652
+
653
+ [[webflux-filters-forwarded-headers]]
654
+ ==== Forwarded Headers
655
+ [.small]#<<web.adoc#filters-forwarded-headers,Same in Spring MVC>>#
656
+
657
+ As a request goes through proxies such as load balancers the host, port, and
658
+ scheme may change presenting a challenge for applications that need to create links
659
+ to resources since the links should reflect the host, port, and scheme of the
660
+ original request as seen from a client perspective.
661
+
662
+ https://tools.ietf.org/html/rfc7239[RFC 7239] defines the "Forwarded" HTTP header
663
+ for proxies to use to provide information about the original request. There are also
664
+ other non-standard headers in use such as "X-Forwarded-Host", "X-Forwarded-Port",
665
+ and "X-Forwarded-Proto".
666
+
667
+ `ForwardedHeaderFilter` detects, extracts, and uses information from the "Forwarded"
668
+ header, or from "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto".
669
+ It wraps the request in order to overlay its host, port, and scheme and also "hides"
670
+ the forwarded headers for subsequent processing.
671
+
672
+ Note that there are security considerations when using forwarded headers as explained
673
+ in Section 8 of RFC 7239. At the application level it is difficult to determine whether
674
+ forwarded headers can be trusted or not. This is why the network upstream should be
675
+ configured correctly to filter out untrusted forwarded headers from the outside.
676
+
677
+ Applications that don't have a proxy and don't need to use forwarded headers can
678
+ configure the `ForwardedHeaderFilter` to remove and ignore such headers.
679
+
680
+
681
+ [[webflux-filters-cors]]
682
+ ==== CORS
683
+ [.small]#<<web.adoc#filters-cors,Same in Spring MVC>>#
684
+
685
+ Spring WebFlux provides fine-grained support for CORS configuration through annotations on
686
+ controllers. However when used with Spring Security it is advisable to rely on the built-in
687
+ `CorsFilter` that must be ordered ahead of Spring Security's chain of filters.
688
+
689
+ See the section on <<webflux-cors>> and the <<webflux-cors-webfilter>> for more details.
690
+
691
+
692
+
644
693
645
694
[[webflux-dispatcher-handler]]
646
695
== DispatcherHandler
@@ -657,7 +706,7 @@ for access to the context it runs in. If `DispatcherHandler` is declared with th
657
706
name "webHandler" it is in turn discovered by
658
707
{api-spring-framework}/web/server/adapter/WebHttpHandlerBuilder.html[WebHttpHandlerBuilder]
659
708
which puts together a request processing chain as described in
660
- <<webflux-web-handler-api,WebHandler API >>.
709
+ <<webflux-web-handler-api>>.
661
710
662
711
Spring configuration in a WebFlux application typically contains:
663
712
@@ -854,44 +903,6 @@ views through the <<webflux-config-view-resolvers,WebFlux Config>>. Default view
854
903
always selected and used if they match the requested media type.
855
904
856
905
857
- [[webflux-filters]]
858
- == Filters
859
- [.small]#<<web.adoc#filters,Same in Spring MVC>>#
860
-
861
- As part of the <<webflux-web-handler-api>>, the `spring-web` module provides a number of
862
- `WebFilter` implementations.
863
-
864
-
865
-
866
- [[webflux-filters-forwarded-headers]]
867
- === Forwarded Headers
868
- [.small]#<<web.adoc#filters-forwarded-headers,Same in Spring MVC>>#
869
-
870
- As a request goes through proxies such as load balancers the host, port, and
871
- scheme may change presenting a challenge for applications that need to create links
872
- to resources since the links should reflect the host, port, and scheme of the
873
- original request as seen from a client perspective.
874
-
875
- https://tools.ietf.org/html/rfc7239[RFC 7239] defines the "Forwarded" HTTP header
876
- for proxies to use to provide information about the original request. There are also
877
- other non-standard headers in use such as "X-Forwarded-Host", "X-Forwarded-Port",
878
- and "X-Forwarded-Proto".
879
-
880
- `ForwardedHeaderFilter` detects, extracts, and uses information from the "Forwarded"
881
- header, or from "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto".
882
- It wraps the request in order to overlay its host, port, and scheme and also "hides"
883
- the forwarded headers for subsequent processing.
884
-
885
- Note that there are security considerations when using forwarded headers as explained
886
- in Section 8 of RFC 7239. At the application level it is difficult to determine whether
887
- forwarded headers can be trusted or not. This is why the network upstream should be
888
- configured correctly to filter out untrusted forwarded headers from the outside.
889
-
890
- Applications that don't have a proxy and don't need to use forwarded headers can
891
- configure the `ForwardedHeaderFilter` to remove and ignore such headers.
892
-
893
-
894
-
895
906
896
907
897
908
[[webflux-controller]]
0 commit comments