Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support checkpoint urls that require cookies #111

Open
rtyley opened this issue Jul 27, 2023 · 0 comments
Open

Support checkpoint urls that require cookies #111

rtyley opened this issue Jul 27, 2023 · 0 comments

Comments

@rtyley
Copy link
Member

rtyley commented Jul 27, 2023

Some Guardian endpoints like https://support.theguardian.com/uk/contribute now require an Okta cookie, and will redirect endlessly if the cookie can't be dropped (see eg guardian/support-frontend#5152 (comment)):

$ curl -I https://support.theguardian.com/uk/contribute
HTTP/2 303
location: /oauth/authorize

Giving us an error like this:

Could not read from this url, got java.net.ProtocolException: Too many follow-up requests: 21

We wouldn't want Prout to maintain cookies across separate checkpoint snapshots (each snapshot should be isolated), but when taking a single snapshot, which might redirect (eg in order to acquire cookies), it could be that we do want to maintain cookies.

Prout currently uses OkHttp as the HTTP client used to take checkpoint snapshots:

val client = new OkHttpClient()

Switch HTTP client to java.net.http.HttpClient ?

Documentation on how to get OkHttp to store cookies between requests (with a CookieJar) is limited, but Java 9 introduced an alternative HTTP client, java.net.http.HttpClient:

...which seems to supply all of Prout's requirements in a HTTP client, including this new one for cookies:

Of course, switching to the JDK HTTP client would also mean we'd get to drop a dependency, which would be nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant