enonic / lib-http-client

Http Client Library for Enonic XP.
Apache License 2.0
0 stars 4 forks source link

Add an option to avoid following redirects #13

Closed aro closed 6 years ago

aro commented 6 years ago

Currently if the server responds with a redirect status (3xx), the library handles it and will return the latest non 3xx response to the caller.

Add an option to avoid following the redirects to have more control. This is useful for example if there are multiple cookies returned in the different redirects.

ComLock commented 6 years ago

Have a look at http://lvh.no/naar_det_haster/abcde__primaer-_og_sekundaerundersoekelsen/abcde-prinsipper

It goes like this:

  1. Request: lvh.no without any cookies Respond: Set cookie tibet_access on lvh.no and redirect to tibet.gyldendal.no

  2. Request tibet.gyldendal.no with previous tibet_session cookie Respons: Set cookie tibet_session on tibet.gyldendal.no and redirect to lvh.no?redirect_from_tibet=true

  3. Request lvh.no?redirect_from_tibet=true with tibet_access cookie (from step 1) Respond: redirect to lvh.no no set-cookie headers

  4. Request lvh.no with tibet_access cookie (from step 1) Respond 200 with set cookie _legevakt_session (edited)

ComLock commented 6 years ago

I would rather the internal redirect handling support cookies correctly, than implementing a session on my own.