dependencies: Upgrade cookie and rename Servo's Cookie to ServoCookie (#32861)

This changes updates to the new version of the `cookie` crate in Servo
which no longer uses the old `time@0.1` data types. This requires using
a new version of `time` while we transition off of the old one. This is
the first step in that process.

In addition, the overloading of the `cookie::Cookie` name was causing a
great deal of confusion, so I've renamed the Servo wrapper to
`ServoCookie` like we do with `ServoUrl`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-07-26 18:13:39 +02:00 committed by GitHub
parent 8f377a0cb1
commit b6f1e3b22d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 203 additions and 199 deletions

View file

@ -20,6 +20,7 @@ use base::id::{BrowsingContextId, TopLevelBrowsingContextId};
use base64::Engine;
use capabilities::ServoCapabilities;
use compositing_traits::ConstellationMsg;
use cookie::{CookieBuilder, Expiration};
use crossbeam_channel::{after, select, unbounded, Receiver, Sender};
use euclid::{Rect, Size2D};
use http::method::Method;
@ -92,9 +93,10 @@ fn cookie_msg_to_cookie(cookie: cookie::Cookie) -> Cookie {
value: cookie.value().to_owned(),
path: cookie.path().map(|s| s.to_owned()),
domain: cookie.domain().map(|s| s.to_owned()),
expiry: cookie
.expires()
.map(|time| Date(time.to_timespec().sec as u64)),
expiry: cookie.expires().and_then(|expiration| match expiration {
Expiration::DateTime(date_time) => Some(Date(date_time.unix_timestamp() as u64)),
Expiration::Session => None,
}),
secure: cookie.secure().unwrap_or(false),
http_only: cookie.http_only().unwrap_or(false),
same_site: cookie.same_site().map(|s| s.to_string()),
@ -1254,19 +1256,19 @@ impl Handler {
) -> WebDriverResult<WebDriverResponse> {
let (sender, receiver) = ipc::channel().unwrap();
let cookie = cookie::Cookie::build(params.name.to_owned(), params.value.to_owned())
let cookie_builder = CookieBuilder::new(params.name.to_owned(), params.value.to_owned())
.secure(params.secure)
.http_only(params.httpOnly);
let cookie = match params.domain {
Some(ref domain) => cookie.domain(domain.to_owned()),
_ => cookie,
let cookie_builder = match params.domain {
Some(ref domain) => cookie_builder.domain(domain.to_owned()),
_ => cookie_builder,
};
let cookie = match params.path {
Some(ref path) => cookie.path(path.to_owned()).finish(),
_ => cookie.finish(),
let cookie_builder = match params.path {
Some(ref path) => cookie_builder.path(path.to_owned()),
_ => cookie_builder,
};
let cmd = WebDriverScriptCommand::AddCookie(cookie, sender);
let cmd = WebDriverScriptCommand::AddCookie(cookie_builder.build(), sender);
self.browsing_context_script_command(cmd)?;
match receiver.recv().unwrap() {
Ok(_) => Ok(WebDriverResponse::Void),