Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ fn is_header_allowed(header: &str) -> bool {
!matches!(
header,
"host"
| "authorization"
| "origin"
| "referer"
| "cookie"
| "etag"
| "content-length"
| "set-cookie"
| "alt-svc"
Expand Down Expand Up @@ -506,4 +511,4 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {

// Stream response
Ok(response.streaming(resp.bytes_stream()))
}
}
8 changes: 6 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use once_cell::sync::Lazy;
use qstring::QString;
use reqwest::Url;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::env;

static PREFIX_PATH: Lazy<String> = Lazy::new(|| String::from(env::var("PREFIX_PATH").unwrap_or_else(|_| "".to_string())));

pub fn read_buf(buf: &[u8], pos: &mut usize) -> u8 {
let byte = buf[*pos];
Expand Down Expand Up @@ -46,12 +50,12 @@ fn finalize_url(path: &str, query: BTreeMap<String, String>) -> String {
if qhash.is_some() {
let mut query = QString::new(query.into_iter().collect::<Vec<_>>());
query.add_pair(("qhash", qhash.unwrap()));
return format!("{}?{}", path, query);
Copy link
Member

Choose a reason for hiding this comment

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

We need feature specific code for when prefix-path enabled and not.

Copy link
Author

Choose a reason for hiding this comment

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

hi @FireMasterK , please let me know if my solution is what you meant. thanks

return format!("{}{}?{}", PREFIX_PATH.as_str(), path, query);
}
}

let query = QString::new(query.into_iter().collect::<Vec<_>>());
format!("{}?{}", path, query)
format!("{}{}?{}", PREFIX_PATH.as_str(), path, query)
}

pub fn localize_url(url: &str, host: &str) -> String {
Expand Down