Xuanwo commented on code in PR #4029:
URL: https://github.com/apache/opendal/pull/4029#discussion_r1461453061


##########
core/src/services/icloud/core.rs:
##########
@@ -111,94 +115,100 @@ impl Debug for IcloudSigner {
 impl IcloudSigner {
     /// Get the drivews_url from signer session data.
     /// Async await init finish.
-    pub async fn drivews_url(&mut self) -> Result<String> {
-        self.init().await?;
-        Ok(self.data.drivews_url.clone())
+    pub async fn drivews_url(&mut self) -> Result<&str> {
+        if !self.initiated {
+            self.init().await?;

Review Comment:
   self.init() has checked `initiated`, we don't need to double check it.



##########
core/src/services/icloud/core.rs:
##########
@@ -80,6 +82,8 @@ impl SessionData {
             session_token: None,
             scnt: None,
             account_country: None,
+
+            cookies: Default::default(),

Review Comment:
   OpenDAL's code should be optimized for readability. Using 
`Default::default()` can make it difficult for readers to determine the type. 
Please use `BTreeMap::default()` instead.



##########
core/src/services/icloud/core.rs:
##########
@@ -249,6 +285,18 @@ impl IcloudSigner {
             self.data.scnt = Some(scnt.to_string());
         }
 
+        for (key, value) in resp.headers() {

Review Comment:
   Please don't loop the entire headers to find `SET_COOKIE`. Use `get_all` 
instead.



##########
core/src/services/icloud/core.rs:
##########
@@ -224,6 +248,19 @@ impl IcloudSigner {
             );
         }
 
+        if !self.data.cookies.is_empty() {
+            let cookies: Vec<String> = self
+                .data
+                .cookies
+                .iter()
+                .map(|(k, v)| format!("{}={}", k, v))
+                .collect();
+            headers.insert(
+                header::COOKIE,
+                cookies.as_slice().join("; ").parse().unwrap(),

Review Comment:
   Please use `build_header_value` instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to