mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #9662 - rebstar6:websocket_cookies, r=jdm
Add support for websocket cookies Addresses both cookies in request and response. Resolves #9540. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9662) <!-- Reviewable:end -->
This commit is contained in:
commit
bc034845b7
9 changed files with 23 additions and 32 deletions
|
@ -29,7 +29,8 @@ use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue};
|
|||
use js::jsapi::{JS_GetArrayBufferData, JS_NewArrayBuffer};
|
||||
use js::jsval::UndefinedValue;
|
||||
use libc::{uint32_t, uint8_t};
|
||||
use net_traits::ControlMsg::WebsocketConnect;
|
||||
use net_traits::ControlMsg::{WebsocketConnect, SetCookiesForUrl};
|
||||
use net_traits::CookieSource::HTTP;
|
||||
use net_traits::MessageData;
|
||||
use net_traits::hosts::replace_hosts;
|
||||
use net_traits::unwrap_websocket_protocol;
|
||||
|
@ -485,6 +486,15 @@ impl Runnable for ConnectionEstablishedTask {
|
|||
};
|
||||
|
||||
// Step 5: Cookies.
|
||||
if let Some(cookies) = self.headers.get_raw("set-cookie") {
|
||||
for cookie in cookies.iter() {
|
||||
if let Ok(cookie_value) = String::from_utf8(cookie.clone()) {
|
||||
let _ = ws.global().r().resource_thread().send(SetCookiesForUrl(ws.url.clone(),
|
||||
cookie_value,
|
||||
HTTP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 6.
|
||||
ws.upcast().fire_simple_event("open");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue