mirror of
https://github.com/epi052/feroxbuster.git
synced 2026-06-06 08:51:12 -03:00
cleaned up make_request, ran fmt
This commit is contained in:
@@ -106,7 +106,13 @@ pub struct FeroxResponse {
|
||||
/// Implement Display for FeroxResponse
|
||||
impl fmt::Display for FeroxResponse {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "FeroxResponse {{ url: {}, status: {}, content-length: {} }}", self.url(), self.status(), self.content_length())
|
||||
write!(
|
||||
f,
|
||||
"FeroxResponse {{ url: {}, status: {}, content-length: {} }}",
|
||||
self.url(),
|
||||
self.status(),
|
||||
self.content_length()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ pub fn initialize(verbosity: u8) {
|
||||
record.target(),
|
||||
style(record.args()).dim(),
|
||||
);
|
||||
|
||||
PROGRESS_PRINTER.println(&msg);
|
||||
|
||||
if let Some(buffered_file) = locked_file.clone() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::config::{CONFIGURATION, PROGRESS_PRINTER};
|
||||
use crate::utils::{create_report_string, ferox_print, make_request, status_colorizer};
|
||||
use crate::utils::{create_report_string, ferox_print, make_request};
|
||||
use crate::{FeroxChannel, FeroxResponse};
|
||||
use console::strip_ansi_codes;
|
||||
use std::io::Write;
|
||||
|
||||
@@ -311,10 +311,7 @@ fn response_is_directory(response: &FeroxResponse) -> bool {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
log::debug!(
|
||||
"expected Location header, but none was found: {}",
|
||||
response
|
||||
);
|
||||
log::debug!("expected Location header, but none was found: {}", response);
|
||||
log::trace!("exit: is_directory -> false");
|
||||
return false;
|
||||
}
|
||||
|
||||
28
src/utils.rs
28
src/utils.rs
@@ -1,8 +1,10 @@
|
||||
use crate::{config::{CONFIGURATION, PROGRESS_PRINTER}, FeroxError, FeroxResult};
|
||||
use crate::{
|
||||
config::{CONFIGURATION, PROGRESS_PRINTER},
|
||||
FeroxError, FeroxResult,
|
||||
};
|
||||
use console::{strip_ansi_codes, style, user_attended};
|
||||
use indicatif::ProgressBar;
|
||||
use reqwest::Url;
|
||||
use reqwest::{Client, Response};
|
||||
use reqwest::{Url, Client, Response};
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use rlimit::{getrlimit, setrlimit, Resource, Rlim};
|
||||
use std::convert::TryInto;
|
||||
@@ -253,14 +255,18 @@ pub async fn make_request(client: &Client, url: &Url) -> FeroxResult<Response> {
|
||||
// only warn for timeouts, while actual errors are still left as errors
|
||||
log::warn!("Error while making request: {}", e);
|
||||
} else if e.is_redirect() {
|
||||
let last_redirect = e.url().unwrap();
|
||||
let fancy_message = format!("{} !=> {}", url, last_redirect);
|
||||
let report = create_report_string(
|
||||
e.status().unwrap().as_str(),
|
||||
"-1",
|
||||
&fancy_message,
|
||||
);
|
||||
ferox_print(&report, &PROGRESS_PRINTER)
|
||||
if let Some(last_redirect) = e.url() {
|
||||
// get where we were headed (last_redirect) and where we came from (url)
|
||||
let fancy_message = format!("{} !=> {}", url, last_redirect);
|
||||
|
||||
let report = if let Some(msg_status) = e.status() {
|
||||
create_report_string(msg_status.as_str(), "-1", &fancy_message)
|
||||
} else {
|
||||
create_report_string("UNK", "-1", &fancy_message)
|
||||
};
|
||||
|
||||
ferox_print(&report, &PROGRESS_PRINTER)
|
||||
};
|
||||
} else {
|
||||
log::error!("Error while making request: {}", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user