Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Do not check connection if local request #9968

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ private HTTPRequest(long nativePtr, String resourceUrl, String etag, String modi
mNativePtr = nativePtr;

try {
// Don't try a request if we aren't connected
if (!Mapbox.isConnected()) {
HttpUrl httpUrl = HttpUrl.parse(resourceUrl);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmrm this code wasn't in the original PR, why was it introduced?

Copy link
Member Author

@tobrun tobrun Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I triple checked it and the code in

try {
HttpUrl httpUrl = HttpUrl.parse(resourceUrl);
final String host = httpUrl.host().toLowerCase(MapboxConstants.MAPBOX_LOCALE);
// Don't try a request to remote server if we aren't connected
if (!Mapbox.isConnected() && !host.equals("127.0.0.1") && !host.equals("localhost")) {
throw new NoRouteToHostException("No Internet connection available.");
}
vs

https://github.com/rjuszczyk/mapbox-gl-native/blob/b113257bf5cf942029edf612313560e0a1c9bf04/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java#L58-L65

is the same except for formatting ( I rebased and fixed-up my formatting commit).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobrun Thanks for checking, it must be a diff artifact.

final String host = httpUrl.host().toLowerCase(MapboxConstants.MAPBOX_LOCALE);

// Don't try a request to remote server if we aren't connected
if (!Mapbox.isConnected() && !host.equals("127.0.0.1") && !host.equals("localhost")) {
throw new NoRouteToHostException("No Internet connection available.");
}

HttpUrl httpUrl = HttpUrl.parse(resourceUrl);
final String host = httpUrl.host().toLowerCase(MapboxConstants.MAPBOX_LOCALE);
if (host.equals("mapbox.com") || host.endsWith(".mapbox.com") || host.equals("mapbox.cn")
|| host.endsWith(".mapbox.cn")) {
if (httpUrl.querySize() == 0) {
Expand Down