mirror of
https://git.42l.fr/neil/sncf.git
synced 2024-05-11 10:16:33 +02:00
more debug info when NC returns bad status code
This commit is contained in:
parent
5014e79b06
commit
be19e37cb7
|
@ -77,6 +77,12 @@ pub async fn create_account(
|
|||
// only 200 http status code is allowed
|
||||
if register_query.status() != 200 {
|
||||
eprintln!("error_createaccount_status: {}", register_query.status());
|
||||
// + extract response body for debugging purposes
|
||||
let response_body = register_query.body().await.map_err(|e| {
|
||||
eprintln!("error_createaccount_post_body: {}", e);
|
||||
crash(lang.clone(), "error_createaccount_post_body")
|
||||
})?;
|
||||
debug(&format!("Body: {:#?}", response_body));
|
||||
return Err(crash(lang.clone(), "error_createaccount_status"));
|
||||
}
|
||||
|
||||
|
@ -150,9 +156,9 @@ pub async fn login(
|
|||
}
|
||||
|
||||
let post_body = login_get.body().await.map_err(|e| {
|
||||
eprintln!("error_login_get_body: {}", e);
|
||||
crash(get_lang(&req), "error_login_get_body")
|
||||
})?;
|
||||
eprintln!("error_login_get_body: {}", e);
|
||||
crash(get_lang(&req), "error_login_get_body")
|
||||
})?;
|
||||
let post_body_str = String::from_utf8_lossy(&post_body);
|
||||
|
||||
// save requesttoken (CSRF) for POST
|
||||
|
@ -162,12 +168,12 @@ pub async fn login(
|
|||
eprintln!("error_login_regex (no capture)");
|
||||
crash(get_lang(&req), "error_login_regex")
|
||||
})?
|
||||
.name("token")
|
||||
.name("token")
|
||||
.ok_or_else(|| {
|
||||
eprintln!("error_login_regex (no capture named token)");
|
||||
crash(get_lang(&req), "error_login_regex")
|
||||
})?
|
||||
.as_str();
|
||||
.as_str();
|
||||
|
||||
// 2. POST /login
|
||||
let mut login_post = client
|
||||
|
@ -186,10 +192,10 @@ pub async fn login(
|
|||
timezone_offset: "2",
|
||||
requesttoken,
|
||||
})
|
||||
.await.map_err(|e| {
|
||||
eprintln!("error_login_post: {}", e);
|
||||
crash(get_lang(&req), "error_login_post")
|
||||
})?;
|
||||
.await.map_err(|e| {
|
||||
eprintln!("error_login_post: {}", e);
|
||||
crash(get_lang(&req), "error_login_post")
|
||||
})?;
|
||||
|
||||
// 3. set the same cookies in the user's browser
|
||||
let mut user_response = HttpResponse::SeeOther();
|
||||
|
|
Loading…
Reference in a new issue