Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update connectivity_util.dart #13

Merged
merged 1 commit into from
May 17, 2020
Merged

Update connectivity_util.dart #13

merged 1 commit into from
May 17, 2020

Conversation

themisir
Copy link
Contributor

Calling "http://www.gstatic.com/generate_204" instead of "google.com" might be more faster and better since google.com returns response body which will take some time also it costs more mobile data.

PS: generate_204 is used for detecting internet connectivity in android, also used for prefetching DNS on chrome, google search and other google products.

Calling "http://www.gstatic.com/generate_204" instead of "google.com" might be more faster and better since google.com returns response body which will take some time also it costs more mobile data.

PS: `generate_204` is used for detecting internet connectivity in android, also used for prefetching DNS on chrome, google search and other google products.
Copy link

@lucalves lucalves left a comment

Choose a reason for hiding this comment

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

Hello, I performed the ping test at the address, but I did not get a return. Could you analyze the link?

@themisir
Copy link
Contributor Author

The curl request runs successfully.

image

Copy link

@lucalves lucalves left a comment

Choose a reason for hiding this comment

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

In my review it's ok.

Copy link
Owner

@Vanethos Vanethos left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -90,7 +90,7 @@ class ConnectivityUtils {

// ignore: close_sinks
final result = await http.get(_serverToPing);
if (result.statusCode == 200 && _callback(result.body)) {
if (result.statusCode > 199 && result.statusCode < 400 && _callback(result.body)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for this, since custom servers might return results other than 200!

@Vanethos
Copy link
Owner

Thanks for the PR! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants