Skip to content

Commit

Permalink
Merge branch 'main' into feature/update-vue-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Nov 13, 2023
2 parents e0e6c61 + 9d006bc commit 06d64fa
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.tencent.mtt.hippy.modules.nativemodules.HippyNativeModuleBase;
import com.tencent.mtt.hippy.runtime.builtins.JSObject;
import com.tencent.vfs.ResourceDataHolder;
import com.tencent.vfs.ResourceDataHolder.TransferType;
import com.tencent.vfs.VfsManager;
import com.tencent.vfs.VfsManager.FetchResourceCallback;
import java.nio.charset.StandardCharsets;
Expand All @@ -54,7 +53,7 @@ public NetworkModule(HippyEngineContext context) {
}

@SuppressWarnings("deprecation")
private void normalizeRequestHeaders(@NonNull HippyMap headers,
protected void normalizeRequestHeaders(@NonNull HippyMap headers,
@NonNull HashMap<String, String> requestHeaders) {
Set<Entry<String, Object>> entrySet = headers.entrySet();
for (Entry<String, Object> entry : entrySet) {
Expand Down Expand Up @@ -82,7 +81,7 @@ private void normalizeRequestHeaders(@NonNull HippyMap headers,
}

@SuppressWarnings("deprecation")
private void normalizeRequest(@NonNull HippyMap request,
protected void normalizeRequest(@NonNull HippyMap request,
@NonNull HashMap<String, String> requestHeaders,
@NonNull HashMap<String, String> requestParams) throws IllegalStateException {
Set<Entry<String, Object>> entrySet = request.entrySet();
Expand All @@ -103,7 +102,7 @@ private void normalizeRequest(@NonNull HippyMap request,
}
}

private void handleFetchResponse(@NonNull ResourceDataHolder dataHolder, Promise promise)
protected void handleFetchResponse(@NonNull ResourceDataHolder dataHolder, Promise promise)
throws IllegalStateException {
JSObject responseObject = new JSObject();
int statusCode = 0;
Expand Down Expand Up @@ -151,12 +150,12 @@ public void fetch(final HippyMap request, final Promise promise) {
try {
normalizeRequest(request, requestHeaders, requestParams);
} catch (Exception e) {
promise.resolve(e.getMessage());
promise.reject(e.getMessage());
return;
}
final String uri = requestParams.get(HTTP_URL);
if (TextUtils.isEmpty(uri)) {
promise.resolve("Get url parameter failed!");
promise.reject("Get url parameter failed!");
return;
}
vfsManager.fetchResourceAsync(uri, requestHeaders, requestParams,
Expand All @@ -168,12 +167,13 @@ public void onFetchCompleted(@NonNull ResourceDataHolder dataHolder) {
try {
handleFetchResponse(dataHolder, promise);
} catch (IllegalStateException e) {
promise.resolve(
"Handle response failed: " + dataHolder.errorMessage);
promise.reject(
"Handle response failed: " + e.getMessage());
}
} else {
promise.resolve(
"Load remote resource failed: " + dataHolder.errorMessage);
String error = TextUtils.isEmpty(dataHolder.errorMessage)
? "Load remote resource failed!" : dataHolder.errorMessage;
promise.resolve(error);
}
dataHolder.recycle();
}
Expand Down

0 comments on commit 06d64fa

Please sign in to comment.