Skip to content

Commit

Permalink
Provide is_online() (#631)
Browse files Browse the repository at this point in the history
Fixes #512
  • Loading branch information
hadley authored Jan 7, 2025
1 parent 17bfc7b commit 2659643
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 83 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export(curl_help)
export(curl_translate)
export(example_github_client)
export(example_url)
export(is_online)
export(iterate_with_cursor)
export(iterate_with_link_url)
export(iterate_with_offset)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# httr2 (development version)

* Export `is_online()` as thin wrapper around `curl::has_internet()` (#512).
* `curl_translate()` now translates cookie headers to `req_cookies_set()` (#431).
* `curl_transform()` will now use `req_body_json_modify()` for JSON data (#258).
* `resp_stream_is_complete()` tells you if there is still data remaining to be streamed (#559).
Expand Down
11 changes: 11 additions & 0 deletions R/is-online.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#' Is your computer currently online?
#'
#' This function uses some cheap heuristics to determine if your computer is
#' currently online. It's a simple wrapper around [curl::has_internet()]
#' exported from httr2 for convenience.
#'
#' @export
#' is_online()
is_online <- function() {
curl::has_internet()
}
166 changes: 83 additions & 83 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,90 +12,90 @@ development:
mode: auto

reference:
- title: Requests
subtitle: Create and modify
contents:
- request
- req_body
- req_cookie_preserve
- req_headers
- req_method
- req_options
- req_progress
- req_proxy
- req_template
- req_timeout
- req_url
- req_user_agent

- subtitle: Debugging/testing
contents:
- last_request
- req_dry_run
- req_verbose
- with_mock
- with_verbosity

- subtitle: Authentication
contents:
- starts_with("req_auth")
- starts_with("req_oauth")

- title: Perform a request
contents:
- req_perform
- req_perform_stream
- req_perform_connection
- req_perform_promise

- subtitle: Control the process
desc: >
These functions don't modify the HTTP request that is sent to the server,
but affect the overall process of `req_perform()`.
contents:
- req_cache
- req_error
- req_throttle
- req_retry

- title: Perform multiple requests
contents:
- req_perform_iterative
- req_perform_parallel
- req_perform_sequential
- starts_with("iterate_")
- starts_with("resps_")

- title: Handle the response
contents:
- starts_with("resp_")

- title: URL manipulation
contents:
- starts_with("url_")

- title: Miscellaenous helpers
contents:
- curl_translate
- secrets
- obfuscate

- title: OAuth
desc: >
These functions implement the low-level components of OAuth.
contents:
- starts_with("oauth_")
- -starts_with("req_oauth")
- title: Requests
subtitle: Create and modify
contents:
- request
- req_body
- req_cookie_preserve
- req_headers
- req_method
- req_options
- req_progress
- req_proxy
- req_template
- req_timeout
- req_url
- req_user_agent

- subtitle: Debugging/testing
contents:
- last_request
- req_dry_run
- req_verbose
- with_mock
- with_verbosity

- subtitle: Authentication
contents:
- starts_with("req_auth")
- starts_with("req_oauth")

- title: Perform a request
contents:
- req_perform
- req_perform_stream
- req_perform_connection
- req_perform_promise

- subtitle: Control the process
desc: >
These functions don't modify the HTTP request that is sent to the server,
but affect the overall process of `req_perform()`.
contents:
- req_cache
- req_error
- req_throttle
- req_retry

- title: Perform multiple requests
contents:
- req_perform_iterative
- req_perform_parallel
- req_perform_sequential
- starts_with("iterate_")
- starts_with("resps_")

- title: Handle the response
contents:
- starts_with("resp_")

- title: URL manipulation
contents:
- starts_with("url_")

- title: Miscellaenous helpers
contents:
- curl_translate
- is_online
- secrets
- obfuscate

- title: OAuth
desc: >
These functions implement the low-level components of OAuth.
contents:
- starts_with("oauth_")
- -starts_with("req_oauth")

articles:
- title: Using httr2
navbar: ~
contents:
- articles/wrapping-apis
- articles/oauth

- title: Using httr2
navbar: ~
contents:
- articles/wrapping-apis
- articles/oauth

news:
releases:
- text: "httr2 1.0.0"
href: https://www.tidyverse.org/blog/2023/11/httr2-1-0-0/
releases:
- text: "httr2 1.0.0"
href: https://www.tidyverse.org/blog/2023/11/httr2-1-0-0/
13 changes: 13 additions & 0 deletions man/is_online.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2659643

Please sign in to comment.