submissions-api: fix cookie

This commit is contained in:
Quaternions 2024-12-19 16:27:11 -08:00
parent a7e9dbb94d
commit b3ffbe4b50

View File

@ -1,8 +1,9 @@
pub struct Cookie(reqwest::header::HeaderValue); pub struct Cookie(reqwest::header::HeaderValue);
impl Cookie{ impl Cookie{
/// cookie is prepended with "session_id=" by this function
pub fn new(cookie:&str)->Result<Self,reqwest::header::InvalidHeaderValue>{ pub fn new(cookie:&str)->Result<Self,reqwest::header::InvalidHeaderValue>{
Ok(Self(reqwest::header::HeaderValue::from_str(&cookie)?)) Ok(Self(reqwest::header::HeaderValue::from_str(&format!("session_id={}",cookie))?))
} }
} }
@ -19,9 +20,10 @@ impl Context{
base_url, base_url,
client:{ client:{
let mut builder=reqwest::ClientBuilder::new(); let mut builder=reqwest::ClientBuilder::new();
if let Some(cookie)=cookie{ if let Some(mut cookie)=cookie{
cookie.0.set_sensitive(true);
let mut headers=reqwest::header::HeaderMap::new(); let mut headers=reqwest::header::HeaderMap::new();
headers.insert("session_id",cookie.0); headers.insert("Cookie",cookie.0);
builder=builder.default_headers(headers); builder=builder.default_headers(headers);
} }
builder.build()? builder.build()?