mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate OkHttpCompat to Kotlin (#51625)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51625 This just migrates this class to Kotlin, which is also the last class in this package. Changelog: [Internal] [Changed] - Reviewed By: rshest Differential Revision: D75448161 fbshipit-source-id: d5457dd8017fd459d166d2945ff440c303943db2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
66aca66c88
commit
4487697971
@@ -3025,10 +3025,10 @@ public final class com/facebook/react/modules/network/OkHttpClientProvider {
|
||||
public static final fun setOkHttpClientFactory (Lcom/facebook/react/modules/network/OkHttpClientFactory;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/modules/network/OkHttpCompat {
|
||||
public fun <init> ()V
|
||||
public static fun getCookieJarContainer (Lokhttp3/OkHttpClient;)Lcom/facebook/react/modules/network/CookieJarContainer;
|
||||
public static fun getHeadersFromMap (Ljava/util/Map;)Lokhttp3/Headers;
|
||||
public final class com/facebook/react/modules/network/OkHttpCompat {
|
||||
public static final field INSTANCE Lcom/facebook/react/modules/network/OkHttpCompat;
|
||||
public final fun getCookieJarContainer (Lokhttp3/OkHttpClient;)Lcom/facebook/react/modules/network/CookieJarContainer;
|
||||
public final fun getHeadersFromMap (Ljava/util/Map;)Lokhttp3/Headers;
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/modules/network/ProgressListener {
|
||||
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.network;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
/**
|
||||
* Helper class that provides wrappers for compatibility between different OkHttp versions.
|
||||
*
|
||||
* <p>This is required for Kotlin code compatibility, in particular, therefore if you are going to
|
||||
* migrate this file to Kotlin, please first ensure that there is no OkHttp API discrepancy between
|
||||
* different RN platform environments, and then consider getting rid of this compat layer
|
||||
* altogether.
|
||||
*/
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public class OkHttpCompat {
|
||||
public static CookieJarContainer getCookieJarContainer(OkHttpClient client) {
|
||||
return (CookieJarContainer) client.cookieJar();
|
||||
}
|
||||
|
||||
public static Headers getHeadersFromMap(@Nullable Map<String, String> headers) {
|
||||
if (headers == null) {
|
||||
return Headers.of(Collections.emptyMap());
|
||||
} else {
|
||||
return Headers.of(headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
@file:Suppress("DEPRECATION_ERROR") // Conflicting okhttp versions
|
||||
|
||||
package com.facebook.react.modules.network
|
||||
|
||||
import com.facebook.infer.annotation.Nullsafe
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
/**
|
||||
* Helper class that provides wrappers for compatibility between different OkHttp versions.
|
||||
*
|
||||
* This is required for Kotlin code compatibility, in particular, therefore if you are going to
|
||||
* migrate this file to Kotlin, please first ensure that there is no OkHttp API discrepancy between
|
||||
* different RN platform environments, and then consider getting rid of this compat layer
|
||||
* altogether.
|
||||
*/
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public object OkHttpCompat {
|
||||
public fun getCookieJarContainer(client: OkHttpClient): CookieJarContainer =
|
||||
client.cookieJar() as CookieJarContainer
|
||||
|
||||
public fun getHeadersFromMap(headers: Map<String, String>?): Headers =
|
||||
Headers.of(headers ?: emptyMap())
|
||||
}
|
||||
Reference in New Issue
Block a user