-
Notifications
You must be signed in to change notification settings - Fork 106
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
Conversation
There was a problem hiding this 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!
this is opposed to the prev approach where the session file was created when loading it
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
|
I will need to write some tests for this feature |
Fortunately for us, |
There was a problem hiding this 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.
| headers | ||
| .entry(AUTHORIZATION) | ||
| .or_insert(HeaderValue::from_str(&auth)?); |
There was a problem hiding this comment.
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.
| 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)), | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.)
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
developbranch.