mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
libservo: Add a delegate method for HTTP authentication (#35400)
Add a delegate method for HTTP authentication and a related `AuthenticationRequest` object that carries with it the URL as well as whether or not the authentication request is for a proxy or not. This is now separate from the prompt API because requesting authentication doesn't necessarily involve prompting -- this is an implementation detail of the embedder. In addition, the internal bits are cleaned up slightly. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
118a813dba
commit
8486e585f5
9 changed files with 149 additions and 103 deletions
|
@ -28,7 +28,7 @@ use std::sync::{Arc, LazyLock, Mutex, RwLock, Weak};
|
|||
|
||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use devtools_traits::DevtoolsControlMsg;
|
||||
use embedder_traits::{EmbedderMsg, EmbedderProxy, EventLoopWaker};
|
||||
use embedder_traits::{AuthenticationResponse, EmbedderMsg, EmbedderProxy, EventLoopWaker};
|
||||
use futures::future::ready;
|
||||
use http_body_util::combinators::BoxBody;
|
||||
use http_body_util::{BodyExt, Empty, Full};
|
||||
|
@ -125,21 +125,13 @@ fn create_embedder_proxy_and_receiver() -> (EmbedderProxy, Receiver<EmbedderMsg>
|
|||
|
||||
fn receive_credential_prompt_msgs(
|
||||
embedder_receiver: Receiver<EmbedderMsg>,
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
response: Option<AuthenticationResponse>,
|
||||
) -> std::thread::JoinHandle<()> {
|
||||
std::thread::spawn(move || loop {
|
||||
let embedder_msg = embedder_receiver.recv().unwrap();
|
||||
match embedder_msg {
|
||||
embedder_traits::EmbedderMsg::Prompt(_, prompt_definition, _prompt_origin) => {
|
||||
match prompt_definition {
|
||||
embedder_traits::PromptDefinition::Credentials(ipc_sender) => {
|
||||
ipc_sender
|
||||
.send(embedder_traits::PromptCredentialsInput { username, password })
|
||||
.unwrap();
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
embedder_traits::EmbedderMsg::RequestAuthentication(_, _, _, response_sender) => {
|
||||
let _ = response_sender.send(response);
|
||||
break;
|
||||
},
|
||||
embedder_traits::EmbedderMsg::WebResourceRequested(..) => {},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue