Skip to content

Add support for Sessions #125

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

Merged
merged 105 commits into from
Aug 5, 2021
Merged

Add support for Sessions #125

merged 105 commits into from
Aug 5, 2021

Conversation

ducaale
Copy link
Owner

@ducaale ducaale commented Apr 11, 2021

This is an attempt to finish the work started by @plombard in #25. I chose to not reuse the commits from the mentioned PR since it would require a bit of work to rebase it on the develop branch.

Copy link
Collaborator

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

Nice to see this continued!

@ducaale ducaale marked this pull request as ready for review April 14, 2021 21:25
@ducaale
Copy link
Owner Author

ducaale commented Apr 14, 2021

I will need to write some tests for this feature

@ducaale
Copy link
Owner Author

ducaale commented Jun 26, 2021

Session cookies aren't printed with the other request headers. We might have to copy some of reqwest's logic to build it ourselves.

Fortunately for us, CookieStoreMutex already implements the CookieStore trait 🙂.

Copy link
Collaborator

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

Almost there. There's one issue for which we'll have to hear back from HTTPie, but we can fix that after this is merged if necessary.

Comment on lines +180 to +182
headers
.entry(AUTHORIZATION)
.or_insert(HeaderValue::from_str(&auth)?);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not something we have to worry about right now, but keep in mind that authorization can be more complex than simply adding an Authorization: header. I think digest authentication requires a round-trip.

In the long term we could have a trait that each auth method implements, with a method that takes a struct containing mut references to modify the request. Though if we just have basic/bearer/digest then that's still overkill.

Comment on lines +141 to +147
pub fn save_basic_auth(&mut self, username: String, password: Option<String>) {
let password = password.unwrap_or_else(|| "".into());
self.content.auth = Auth {
auth_type: Some("basic".into()),
raw_auth: Some(format!("{}:{}", username, password)),
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if we should store a password the user entered into a prompt instead of on the command line.

HTTPie doesn't work properly in that situation, so I've opened an issue: httpie/cli#1098
Hopefully we'll get clarification there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's just keep it like this for the time being. If you're using --session it's understood that sensitive info may end up on the disk.

@ducaale ducaale mentioned this pull request Jun 28, 2021
6 tasks
Copy link
Collaborator

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

I think this is ready.

(#167 will break some of the tests, so watch out for that.)

@ducaale ducaale merged commit 80ce206 into develop Aug 5, 2021
@ducaale ducaale deleted the sessions branch August 5, 2021 15:56
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

Successfully merging this pull request may close these issues.

2 participants