mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-18 23:38:16 +08:00
Feature/#274 (#281)
* #274 added acceptance tests, need to work out failing unit tests but probably going to be a redesign where we hold a reference to the cookie container and empty it if needed * #274 updated code coverage value * #274 offloaded cache logic to builder in preparation for adding state * #274 hacked something together but this is not right approach * #274 updated defaults and docs * #274 updated code coverage
This commit is contained in:
@ -73,10 +73,17 @@ Follow Redirects / Use CookieContainer
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Use HttpHandlerOptions in ReRoute configuration to set up HttpHandler behavior:
|
||||
- _AllowAutoRedirect_ is a value that indicates whether the request should follow redirection responses.
|
||||
Set it true if the request should automatically follow redirection responses from the Downstream resource; otherwise false. The default value is true.
|
||||
- _UseCookieContainer_ is a value that indicates whether the handler uses the CookieContainer property to store server cookies and uses these cookies when sending requests.
|
||||
The default value is true.
|
||||
|
||||
1. AllowAutoRedirect is a value that indicates whether the request should follow redirection responses. Set it true if the request should automatically
|
||||
follow redirection responses from the Downstream resource; otherwise false. The default value is false.
|
||||
2. UseCookieContainer is a value that indicates whether the handler uses the CookieContainer
|
||||
property to store server cookies and uses these cookies when sending requests. The default value is false. Please note
|
||||
that if you are using the CookieContainer Ocelot caches the HttpClient for each downstream service. This means that all requests
|
||||
to that DownstreamService will share the same cookies. `Issue 274 <https://github.com/ThreeMammals/Ocelot/issues/274>`_ was created because a user
|
||||
noticed that the cookies were being shared. I tried to think of a nice way to handle this but I think it is impossible. If you don't cache the clients
|
||||
that means each request gets a new client and therefore a new cookie container. If you clear the cookies from the cached client container you get race conditions due to inflight
|
||||
requests. This would also mean that subsequent requests dont use the cookies from the previous response! All in all not a great situation. I would avoid setting
|
||||
UseCookieContainer to true unless you have a really really good reason. Just look at your response headers and forward the cookies back with your next request!
|
||||
|
||||
Multiple environments
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -127,4 +134,4 @@ finds your Consul agent and interacts to load and store the configuration from C
|
||||
I decided to create this feature after working on the raft consensus algorithm and finding out its super hard. Why not take advantage of the fact Consul already gives you this!
|
||||
I guess it means if you want to use Ocelot to its fullest you take on Consul as a dependency for now.
|
||||
|
||||
This feature has a 3 second ttl cache before making a new request to your local consul agent.
|
||||
This feature has a 3 second ttl cache before making a new request to your local consul agent.
|
||||
|
Reference in New Issue
Block a user