mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
adding initial support for websocket subprotocol negotation
This commit is contained in:
parent
99fd946130
commit
7d0bede8ba
12 changed files with 87 additions and 49 deletions
|
@ -37,6 +37,7 @@ use std::rc::Rc;
|
|||
use std::thread;
|
||||
use url::Url;
|
||||
use util::mem::HeapSizeOf;
|
||||
use websocket::header;
|
||||
|
||||
pub mod hosts;
|
||||
pub mod image_cache_task;
|
||||
|
@ -239,7 +240,7 @@ pub enum WebSocketDomAction {
|
|||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum WebSocketNetworkEvent {
|
||||
ConnectionEstablished,
|
||||
ConnectionEstablished(header::Headers, Vec<String>),
|
||||
MessageReceived(MessageData),
|
||||
Close,
|
||||
}
|
||||
|
@ -254,6 +255,7 @@ pub struct WebSocketCommunicate {
|
|||
pub struct WebSocketConnectData {
|
||||
pub resource_url: Url,
|
||||
pub origin: String,
|
||||
pub protocols: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
@ -429,6 +431,11 @@ pub fn load_whole_resource(resource_task: &ResourceTask, url: Url, pipeline_id:
|
|||
}
|
||||
}
|
||||
|
||||
/// Defensively unwraps the protocol string from the response object's protocol
|
||||
pub fn unwrap_websocket_protocol(wsp: Option<&header::WebSocketProtocol>) -> Option<&str> {
|
||||
wsp.and_then(|protocol_list| protocol_list.get(0).map(|protocol| protocol.as_ref()))
|
||||
}
|
||||
|
||||
/// An unique identifier to keep track of each load message in the resource handler
|
||||
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
|
||||
pub struct ResourceId(pub u32);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue