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

Cookie Support #1146

Merged
merged 6 commits into from
Jul 13, 2023
Merged

Cookie Support #1146

merged 6 commits into from
Jul 13, 2023

Conversation

mre
Copy link
Member

@mre mre commented Jul 8, 2023

This is a very conservative and limited implementation of cookie support.

The goal is to ship an MVP, which covers 80% of the use-cases.
When you run lychee with --cookie-jar cookies.json, all cookies will be stored in cookies.json, one cookie per line.
This makes cookies easy to edit by hand if needed, although this is an advanced use-case and the API for the format is not guaranteed to be stable.

My initial goal was to use the same cookie file format that curl uses, but I backed away from this thought for a few reasons:

  • The cookie file format is an implementation detail: people should not rely on the format to never change.
  • There is on Rust implementation for the curl format out there, so we'd have to roll our own, test it, and maintain it, which sounds like unnecessary work.
    So, at least for now, we use reqwest_cookie_store under the hood.

Fixes: #645, #715
Partially fixes: #1108 (comment)

Reviews/feedback welcome!


Note: I had to change an unrelated unit test for invalid status codes, because it was flaky, and I wanted the CI pipeline to be green before merging.

@mre mre force-pushed the cookie-support-v2 branch 12 times, most recently from 9d1968b to 2ae9ac6 Compare July 8, 2023 16:50
@@ -46,7 +46,7 @@ where
let cache = params.cache;
let accept = params.cfg.accept;

let pb = if params.cfg.no_progress {
let pb = if params.cfg.no_progress || params.cfg.verbose.log_level() >= log::Level::Info {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here, because showing the progress bar in verbose mode makes the output harder to read. It's not related to the other changes in this PR, but I got annoyed by the output while troubleshooting, so I fixed it in one go.

lychee-bin/src/main.rs Outdated Show resolved Hide resolved
@mre
Copy link
Member Author

mre commented Jul 8, 2023

I am wondering if we should enable cookies by default. So if the user didn't set a custom cookie jar file, we still enable cookie support for this "link check session". After that, we throw the jar away. This would handle more cases, like #715. Opinions?

@mre mre merged commit 14e7487 into master Jul 13, 2023
6 checks passed
@mre mre deleted the cookie-support-v2 branch July 13, 2023 15:32
stefankreutz added a commit to stefankreutz/lychee that referenced this pull request Aug 2, 2023
Commit 14e7487 (cookie support lycheeverse#1146) re-introduced an unconditional
dependency on the openssl-sys crate. That is, building Lychee with the
Rustls TLS backend now requires OpenSSL. I suppose this change was
unintended, maybe due to automatic conflict resolution. If not, please
let me know.

You can review the re-introduced dependency like so:

```
cargo tree --no-default-features --features rustls-tls -i openssl-sys
```

This commit puts the OpenSSL dependency behind the native-tls feature
flag again.

You can check the TLS features like so:

```
cargo check --workspace --all-targets --features vendored-openssl

cargo check --workspace --all-targets --all-features

cargo check --workspace --all-targets --no-default-features --features rustls-tls
```

Maybe this should be added to CI. But I don't want to waste anybody's
time.
mre pushed a commit that referenced this pull request Aug 4, 2023
* Fix rustls-tls feature

Commit 14e7487 (cookie support #1146) re-introduced an unconditional
dependency on the openssl-sys crate. That is, building Lychee with the
Rustls TLS backend now requires OpenSSL. I suppose this change was
unintended, maybe due to automatic conflict resolution. If not, please
let me know.

You can review the re-introduced dependency like so:

```
cargo tree --no-default-features --features rustls-tls -i openssl-sys
```

This commit puts the OpenSSL dependency behind the native-tls feature
flag again.

You can check the TLS features like so:

```
cargo check --workspace --all-targets --features vendored-openssl

cargo check --workspace --all-targets --all-features

cargo check --workspace --all-targets --no-default-features --features rustls-tls
```

Maybe this should be added to CI. But I don't want to waste anybody's
time.

* Check feature flags during CI

Adds a new CI job 'check-feature-flags' to verify the following:

- Lychee with rustls-tls feature only doesn't depend on OpenSSL
- Cargo check passes with default features
- Cargo check passes with all features
- Cargo check passes with rustls-tls feature only
@mre mre added the enhancement New feature or request label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Twitter link sharing URL check returns 404 Add cookie support?
1 participant