Skip to content

Commit

Permalink
Convert Network Module [4]
Browse files Browse the repository at this point in the history
Summary:
Fourth batch of conversions for the module - everything but NetworkingModule.java converted
Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D56155523
  • Loading branch information
Thomas Nardone authored and facebook-github-bot committed Jun 7, 2024
1 parent 153b755 commit 82f0fb0
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 314 deletions.
20 changes: 10 additions & 10 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -3511,16 +3511,16 @@ public final class com/facebook/react/modules/network/ReactCookieJarContainer :
public fun setCookieJar (Lokhttp3/CookieJar;)V
}

public class com/facebook/react/modules/network/ResponseUtil {
public fun <init> ()V
public static fun onDataReceived (Lcom/facebook/react/bridge/ReactApplicationContext;ILcom/facebook/react/bridge/WritableMap;)V
public static fun onDataReceived (Lcom/facebook/react/bridge/ReactApplicationContext;ILjava/lang/String;)V
public static fun onDataReceivedProgress (Lcom/facebook/react/bridge/ReactApplicationContext;IJJ)V
public static fun onDataSend (Lcom/facebook/react/bridge/ReactApplicationContext;IJJ)V
public static fun onIncrementalDataReceived (Lcom/facebook/react/bridge/ReactApplicationContext;ILjava/lang/String;JJ)V
public static fun onRequestError (Lcom/facebook/react/bridge/ReactApplicationContext;ILjava/lang/String;Ljava/lang/Throwable;)V
public static fun onRequestSuccess (Lcom/facebook/react/bridge/ReactApplicationContext;I)V
public static fun onResponseReceived (Lcom/facebook/react/bridge/ReactApplicationContext;IILcom/facebook/react/bridge/WritableMap;Ljava/lang/String;)V
public final class com/facebook/react/modules/network/ResponseUtil {
public static final field INSTANCE Lcom/facebook/react/modules/network/ResponseUtil;
public static final fun onDataReceived (Lcom/facebook/react/bridge/ReactApplicationContext;ILcom/facebook/react/bridge/WritableMap;)V
public static final fun onDataReceived (Lcom/facebook/react/bridge/ReactApplicationContext;ILjava/lang/String;)V
public static final fun onDataReceivedProgress (Lcom/facebook/react/bridge/ReactApplicationContext;IJJ)V
public static final fun onDataSend (Lcom/facebook/react/bridge/ReactApplicationContext;IJJ)V
public static final fun onIncrementalDataReceived (Lcom/facebook/react/bridge/ReactApplicationContext;ILjava/lang/String;JJ)V
public static final fun onRequestError (Lcom/facebook/react/bridge/ReactApplicationContext;ILjava/lang/String;Ljava/lang/Throwable;)V
public static final fun onRequestSuccess (Lcom/facebook/react/bridge/ReactApplicationContext;I)V
public static final fun onResponseReceived (Lcom/facebook/react/bridge/ReactApplicationContext;IILcom/facebook/react/bridge/WritableMap;Ljava/lang/String;)V
}

public final class com/facebook/react/modules/network/TLSSocketFactory : javax/net/ssl/SSLSocketFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void onProgress(long bytesWritten, long contentLength, boolean done) {
if (data == null
|| method.toLowerCase(Locale.ROOT).equals("get")
|| method.toLowerCase(Locale.ROOT).equals("head")) {
requestBody = RequestBodyUtil.getEmptyBody(method);
requestBody = RequestBodyUtil.INSTANCE.getEmptyBody(method);
} else if (handler != null) {
requestBody = handler.toRequestBody(data, contentType);
} else if (data.hasKey(REQUEST_BODY_KEY_STRING)) {
Expand All @@ -391,8 +391,8 @@ public void onProgress(long bytesWritten, long contentLength, boolean done) {
}
String body = data.getString(REQUEST_BODY_KEY_STRING);
MediaType contentMediaType = MediaType.parse(contentType);
if (RequestBodyUtil.isGzipEncoding(contentEncoding)) {
requestBody = RequestBodyUtil.createGzip(contentMediaType, body);
if (RequestBodyUtil.INSTANCE.isGzipEncoding(contentEncoding)) {
requestBody = RequestBodyUtil.INSTANCE.createGzip(contentMediaType, body);
if (requestBody == null) {
ResponseUtil.onRequestError(
reactApplicationContext, requestId, "Failed to gzip request body", null);
Expand Down Expand Up @@ -431,13 +431,13 @@ public void onProgress(long bytesWritten, long contentLength, boolean done) {
}
String uri = data.getString(REQUEST_BODY_KEY_URI);
InputStream fileInputStream =
RequestBodyUtil.getFileInputStream(getReactApplicationContext(), uri);
RequestBodyUtil.INSTANCE.getFileInputStream(getReactApplicationContext(), uri);
if (fileInputStream == null) {
ResponseUtil.onRequestError(
reactApplicationContext, requestId, "Could not retrieve file for uri " + uri, null);
return;
}
requestBody = RequestBodyUtil.create(MediaType.parse(contentType), fileInputStream);
requestBody = RequestBodyUtil.INSTANCE.create(MediaType.parse(contentType), fileInputStream);
} else if (data.hasKey(REQUEST_BODY_KEY_FORMDATA)) {
if (contentType == null) {
contentType = "multipart/form-data";
Expand All @@ -451,7 +451,7 @@ public void onProgress(long bytesWritten, long contentLength, boolean done) {
requestBody = multipartBuilder.build();
} else {
// Nothing in data payload, at least nothing we could understand anyway.
requestBody = RequestBodyUtil.getEmptyBody(method);
requestBody = RequestBodyUtil.INSTANCE.getEmptyBody(method);
}

requestBuilder.method(method, wrapRequestBodyWithProgressEmitter(requestBody, requestId));
Expand Down Expand Up @@ -571,7 +571,7 @@ private RequestBody wrapRequestBodyWithProgressEmitter(
}
final ReactApplicationContext reactApplicationContext =
getReactApplicationContextIfActiveOrWarn();
return RequestBodyUtil.createProgressRequest(
return RequestBodyUtil.INSTANCE.createProgressRequest(
requestBody,
new ProgressListener() {
long last = System.nanoTime();
Expand Down Expand Up @@ -732,7 +732,8 @@ public void removeListeners(double count) {}
}
String fileContentUriStr = bodyPart.getString(REQUEST_BODY_KEY_URI);
InputStream fileInputStream =
RequestBodyUtil.getFileInputStream(getReactApplicationContext(), fileContentUriStr);
RequestBodyUtil.INSTANCE.getFileInputStream(
getReactApplicationContext(), fileContentUriStr);
if (fileInputStream == null) {
ResponseUtil.onRequestError(
reactApplicationContext,
Expand All @@ -741,7 +742,8 @@ public void removeListeners(double count) {}
null);
return null;
}
multipartBuilder.addPart(headers, RequestBodyUtil.create(partContentType, fileInputStream));
multipartBuilder.addPart(
headers, RequestBodyUtil.INSTANCE.create(partContentType, fileInputStream));
} else {
ResponseUtil.onRequestError(
reactApplicationContext, requestId, "Unrecognized FormData part.", null);
Expand Down

This file was deleted.

Loading

0 comments on commit 82f0fb0

Please sign in to comment.