Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #100 from PThorpe92/dev
Browse files Browse the repository at this point in the history
fix: small fixes
  • Loading branch information
PThorpe92 authored Nov 19, 2023
2 parents 776619f + 847fb25 commit fe20ce3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ impl<'a> App<'a> {

AppOptions::Outfile(outfile) => self.command.as_mut().unwrap().set_outfile(&outfile),

AppOptions::Cookie(cookie) => self.command.as_mut().unwrap().add_cookie(cookie),
AppOptions::Cookie(cookie) => self.command.as_mut().unwrap().add_cookie(&cookie),

AppOptions::RecDownload(i) => self.command.as_mut().unwrap().set_rec_download_level(i),

Expand Down Expand Up @@ -507,7 +507,7 @@ impl<'a> App<'a> {
AppOptions::Cookie(_) => {
if let AppOptions::Cookie(ref mut cookie) = opt {
option.replace_value(cookie.clone());
self.command.as_mut().unwrap().add_cookie(cookie.clone());
self.command.as_mut().unwrap().add_cookie(cookie);
}
}
AppOptions::CaPath(_) => {
Expand Down
4 changes: 2 additions & 2 deletions src/request/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<'a> CmdOpts for Cmd<'a> {
}

impl<'a> CurlOpts for Cmd<'a> {
fn add_cookie(&mut self, cookie: String) {
fn add_cookie(&mut self, cookie: &str) {
if let Cmd::Curl(curl) = self {
curl.add_cookie(cookie);
}
Expand Down Expand Up @@ -264,7 +264,7 @@ pub trait CurlOpts {
fn set_content_header(&mut self, kind: HeaderKind);
fn set_request_body(&mut self, body: &str);
fn set_upload_file(&mut self, file: &str);
fn add_cookie(&mut self, cookie: String);
fn add_cookie(&mut self, cookie: &str);
fn set_follow_redirects(&mut self, opt: bool);
fn set_proxy_tunnel(&mut self, opt: bool);
fn match_wildcard(&mut self, opt: bool);
Expand Down
13 changes: 5 additions & 8 deletions src/request/curl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,10 @@ impl<'a> CurlOpts for Curl<'a> {
self.curl.follow_location(opt).unwrap();
}

fn add_cookie(&mut self, cookie: String) {
// we are removing it
let flag = CurlFlag::Cookie(CurlFlagType::Cookie.get_value(), Some(cookie.clone()));
fn add_cookie(&mut self, cookie: &str) {
let flag = CurlFlag::Cookie(CurlFlagType::Cookie.get_value(), Some(String::from(cookie)));
self.toggle_flag(&flag);
self.curl.cookie(cookie.as_str()).unwrap();
self.curl.cookie(cookie).unwrap();
}

fn set_upload_file(&mut self, file: &str) {
Expand Down Expand Up @@ -658,9 +657,7 @@ impl<'a> Curl<'a> {
fn has_flag(&self, flag: &CurlFlag<'a>) -> bool {
self.opts
.iter()
.filter(|has| std::mem::discriminant(*has) == std::mem::discriminant(flag))
.count()
> 0
.any(|has| std::mem::discriminant(has) == std::mem::discriminant(flag))
}

// This is a hack because when we deseialize json from the DB, we get a curl struct with no curl::Easy
Expand Down Expand Up @@ -691,7 +688,7 @@ impl<'a> Curl<'a> {
}
CurlFlag::Cookie(..) => {
if let Some(val) = opt.get_arg() {
self.add_cookie(val);
self.add_cookie(&val);
}
}
CurlFlag::MatchWildcard(..) => {
Expand Down
7 changes: 3 additions & 4 deletions src/screens/input/request_body_input.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::app::{App, InputMode};
use crate::display::inputopt::InputOpt;
use crate::display::AppOptions;
use crate::screens::{default_rect, small_alert_box};
use crate::screens::{default_rect, small_alert_box, Screen};
use tui::text::{Line, Text};
use tui::widgets::{Block, Borders, Paragraph};
use tui::{
Expand Down Expand Up @@ -77,8 +77,7 @@ pub fn handle_req_body_input_screen<B: Backend>(
}
// we have input (the user has typed something and pressed Enter while in insert mode)
if !app.messages.is_empty() {
app.add_app_option(AppOptions::RequestBody(
app.messages.iter().map(|x| x.to_string()).collect(),
));
app.add_app_option(AppOptions::RequestBody(app.messages[0].clone()));
app.goto_screen(Screen::RequestMenu(String::new()));
}
}

0 comments on commit fe20ce3

Please sign in to comment.