mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-25 10:18:31 +02:00
Always update response if error
https://feedback.yaak.app/p/cant-re-send-request-if-there-is-one-ongoing
This commit is contained in:
@@ -167,9 +167,9 @@ pub async fn send_http_request<R: Runtime>(
|
|||||||
let cookies = cj
|
let cookies = cj
|
||||||
.cookies
|
.cookies
|
||||||
.iter()
|
.iter()
|
||||||
.map(|cookie| {
|
.filter_map(|cookie| {
|
||||||
let json_cookie = serde_json::to_value(cookie).unwrap();
|
let json_cookie = serde_json::to_value(cookie).ok()?;
|
||||||
serde_json::from_value(json_cookie).expect("Failed to deserialize cookie")
|
serde_json::from_value(json_cookie).ok()?
|
||||||
})
|
})
|
||||||
.map(|c| Ok(c))
|
.map(|c| Ok(c))
|
||||||
.collect::<Vec<Result<_>>>();
|
.collect::<Vec<Result<_>>>();
|
||||||
|
|||||||
@@ -837,13 +837,18 @@ async fn cmd_call_http_request_action<R: Runtime>(
|
|||||||
req: CallHttpRequestActionRequest,
|
req: CallHttpRequestActionRequest,
|
||||||
plugin_manager: State<'_, PluginManager>,
|
plugin_manager: State<'_, PluginManager>,
|
||||||
) -> YaakResult<()> {
|
) -> YaakResult<()> {
|
||||||
Ok(plugin_manager.call_http_request_action(&window, CallHttpRequestActionRequest {
|
Ok(plugin_manager
|
||||||
args: CallHttpRequestActionArgs {
|
.call_http_request_action(
|
||||||
http_request: resolve_http_request(&window, &req.args.http_request)?.0,
|
&window,
|
||||||
..req.args
|
CallHttpRequestActionRequest {
|
||||||
},
|
args: CallHttpRequestActionArgs {
|
||||||
..req
|
http_request: resolve_http_request(&window, &req.args.http_request)?.0,
|
||||||
}).await?)
|
..req.args
|
||||||
|
},
|
||||||
|
..req
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -852,13 +857,18 @@ async fn cmd_call_grpc_request_action<R: Runtime>(
|
|||||||
req: CallGrpcRequestActionRequest,
|
req: CallGrpcRequestActionRequest,
|
||||||
plugin_manager: State<'_, PluginManager>,
|
plugin_manager: State<'_, PluginManager>,
|
||||||
) -> YaakResult<()> {
|
) -> YaakResult<()> {
|
||||||
Ok(plugin_manager.call_grpc_request_action(&window, CallGrpcRequestActionRequest {
|
Ok(plugin_manager
|
||||||
args: CallGrpcRequestActionArgs {
|
.call_grpc_request_action(
|
||||||
grpc_request: resolve_grpc_request(&window, &req.args.grpc_request)?.0,
|
&window,
|
||||||
..req.args
|
CallGrpcRequestActionRequest {
|
||||||
},
|
args: CallGrpcRequestActionArgs {
|
||||||
..req
|
grpc_request: resolve_grpc_request(&window, &req.args.grpc_request)?.0,
|
||||||
}).await?)
|
..req.args
|
||||||
|
},
|
||||||
|
..req
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -980,7 +990,31 @@ async fn cmd_send_http_request<R: Runtime>(
|
|||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
send_http_request(&window, &request, &response, environment, cookie_jar, &mut cancel_rx).await
|
let r = match send_http_request(
|
||||||
|
&window,
|
||||||
|
&request,
|
||||||
|
&response,
|
||||||
|
environment,
|
||||||
|
cookie_jar,
|
||||||
|
&mut cancel_rx,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(e) => {
|
||||||
|
let resp = app_handle.db().get_http_response(&response.id)?;
|
||||||
|
app_handle.db().upsert_http_response(
|
||||||
|
&HttpResponse {
|
||||||
|
state: HttpResponseState::Closed,
|
||||||
|
error: Some(e.to_string()),
|
||||||
|
..resp
|
||||||
|
},
|
||||||
|
&UpdateSource::from_window(&window),
|
||||||
|
)?
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn response_err<R: Runtime>(
|
fn response_err<R: Runtime>(
|
||||||
|
|||||||
Reference in New Issue
Block a user