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

feat: add support for reachabilityMethod to specify GET or HEAD #610

Merged
merged 3 commits into from Jun 28, 2022

Conversation

CaptainJeff
Copy link
Contributor

Overview

Added in support for an optional field in NetInfoConfiguration for reachabilityMethod which accepts either HEAD or GET. Some API endpoints don't support HEAD requests and will return a 405 instead of a 204.

Test Plan

I set my default configuration to

{
  reachabilityUrl: 'https://clients3.google.com/generate_204',
  reachabilityMethod: 'GET',
  reachabilityTest: (response: Response): Promise<boolean> =>
    Promise.resolve(response.status === 204),
  reachabilityShortTimeout: 5 * 1000, // 5s
  reachabilityLongTimeout: 60 * 1000, // 60s
  reachabilityRequestTimeout: 15 * 1000, // 15s
  reachabilityShouldRun: (): boolean => true,
  shouldFetchWiFiSSID: false,
  useNativeReachability: true
};

And was able to verify the request was being made as a GET request instead of HEAD request

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

certainly seems reasonable, and backwards-compatible makes it easy to release, let's see what CI thinks then, sure :-). Thanks for posting this

@mikehardy mikehardy added the pending merge A PR that will be merged shortly, waiting for CI or final comment label Jun 27, 2022
@mikehardy
Copy link
Contributor

formatting -


/home/runner/work/react-native-netinfo/react-native-netinfo/src/internal/types.ts
Warning:   10:13  warning  'NetInfoStateType' is already declared in the upper scope on line 10 column 13           no-shadow
Error:   22:47  error    Insert `;`                                                                               prettier/prettier
Warning:   24:13  warning  'NetInfoCellularGeneration' is already declared in the upper scope on line 24 column 13  no-shadow

I believe the targets are in package.json for local verification?

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

Now it doesn't just look functional but prettier should agree it is pretty as well...

@CaptainJeff
Copy link
Contributor Author

hahahah thanks @mikehardy!!! Appreciate your help, as always

@mikehardy mikehardy changed the title feat: add support for reachabilityMethod feat: add support for reachabilityMethod to specify GET or HEAD Jun 28, 2022
@mikehardy mikehardy merged commit 3f5badd into react-native-netinfo:master Jun 28, 2022
@mikehardy mikehardy removed the pending merge A PR that will be merged shortly, waiting for CI or final comment label Jun 28, 2022
github-actions bot pushed a commit that referenced this pull request Jun 28, 2022
# [9.2.0](v9.1.0...v9.2.0) (2022-06-28)

### Features

* add support for reachabilityMethod to specify GET or HEAD ([#610](#610)) ([3f5badd](3f5badd))
@matt-oakes
Copy link
Collaborator

🎉 This PR is included in version 9.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

3 participants