Skip to content

Commit 2659643

Browse files
authored
Provide is_online() (#631)
Fixes #512
1 parent 17bfc7b commit 2659643

File tree

5 files changed

+109
-83
lines changed

5 files changed

+109
-83
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export(curl_help)
1818
export(curl_translate)
1919
export(example_github_client)
2020
export(example_url)
21+
export(is_online)
2122
export(iterate_with_cursor)
2223
export(iterate_with_link_url)
2324
export(iterate_with_offset)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# httr2 (development version)
22

3+
* Export `is_online()` as thin wrapper around `curl::has_internet()` (#512).
34
* `curl_translate()` now translates cookie headers to `req_cookies_set()` (#431).
45
* `curl_transform()` will now use `req_body_json_modify()` for JSON data (#258).
56
* `resp_stream_is_complete()` tells you if there is still data remaining to be streamed (#559).

R/is-online.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#' Is your computer currently online?
2+
#'
3+
#' This function uses some cheap heuristics to determine if your computer is
4+
#' currently online. It's a simple wrapper around [curl::has_internet()]
5+
#' exported from httr2 for convenience.
6+
#'
7+
#' @export
8+
#' is_online()
9+
is_online <- function() {
10+
curl::has_internet()
11+
}

_pkgdown.yml

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -12,90 +12,90 @@ development:
1212
mode: auto
1313

1414
reference:
15-
- title: Requests
16-
subtitle: Create and modify
17-
contents:
18-
- request
19-
- req_body
20-
- req_cookie_preserve
21-
- req_headers
22-
- req_method
23-
- req_options
24-
- req_progress
25-
- req_proxy
26-
- req_template
27-
- req_timeout
28-
- req_url
29-
- req_user_agent
30-
31-
- subtitle: Debugging/testing
32-
contents:
33-
- last_request
34-
- req_dry_run
35-
- req_verbose
36-
- with_mock
37-
- with_verbosity
38-
39-
- subtitle: Authentication
40-
contents:
41-
- starts_with("req_auth")
42-
- starts_with("req_oauth")
43-
44-
- title: Perform a request
45-
contents:
46-
- req_perform
47-
- req_perform_stream
48-
- req_perform_connection
49-
- req_perform_promise
50-
51-
- subtitle: Control the process
52-
desc: >
53-
These functions don't modify the HTTP request that is sent to the server,
54-
but affect the overall process of `req_perform()`.
55-
contents:
56-
- req_cache
57-
- req_error
58-
- req_throttle
59-
- req_retry
60-
61-
- title: Perform multiple requests
62-
contents:
63-
- req_perform_iterative
64-
- req_perform_parallel
65-
- req_perform_sequential
66-
- starts_with("iterate_")
67-
- starts_with("resps_")
68-
69-
- title: Handle the response
70-
contents:
71-
- starts_with("resp_")
72-
73-
- title: URL manipulation
74-
contents:
75-
- starts_with("url_")
76-
77-
- title: Miscellaenous helpers
78-
contents:
79-
- curl_translate
80-
- secrets
81-
- obfuscate
82-
83-
- title: OAuth
84-
desc: >
85-
These functions implement the low-level components of OAuth.
86-
contents:
87-
- starts_with("oauth_")
88-
- -starts_with("req_oauth")
15+
- title: Requests
16+
subtitle: Create and modify
17+
contents:
18+
- request
19+
- req_body
20+
- req_cookie_preserve
21+
- req_headers
22+
- req_method
23+
- req_options
24+
- req_progress
25+
- req_proxy
26+
- req_template
27+
- req_timeout
28+
- req_url
29+
- req_user_agent
30+
31+
- subtitle: Debugging/testing
32+
contents:
33+
- last_request
34+
- req_dry_run
35+
- req_verbose
36+
- with_mock
37+
- with_verbosity
38+
39+
- subtitle: Authentication
40+
contents:
41+
- starts_with("req_auth")
42+
- starts_with("req_oauth")
43+
44+
- title: Perform a request
45+
contents:
46+
- req_perform
47+
- req_perform_stream
48+
- req_perform_connection
49+
- req_perform_promise
50+
51+
- subtitle: Control the process
52+
desc: >
53+
These functions don't modify the HTTP request that is sent to the server,
54+
but affect the overall process of `req_perform()`.
55+
contents:
56+
- req_cache
57+
- req_error
58+
- req_throttle
59+
- req_retry
60+
61+
- title: Perform multiple requests
62+
contents:
63+
- req_perform_iterative
64+
- req_perform_parallel
65+
- req_perform_sequential
66+
- starts_with("iterate_")
67+
- starts_with("resps_")
68+
69+
- title: Handle the response
70+
contents:
71+
- starts_with("resp_")
72+
73+
- title: URL manipulation
74+
contents:
75+
- starts_with("url_")
76+
77+
- title: Miscellaenous helpers
78+
contents:
79+
- curl_translate
80+
- is_online
81+
- secrets
82+
- obfuscate
83+
84+
- title: OAuth
85+
desc: >
86+
These functions implement the low-level components of OAuth.
87+
contents:
88+
- starts_with("oauth_")
89+
- -starts_with("req_oauth")
8990

9091
articles:
91-
- title: Using httr2
92-
navbar: ~
93-
contents:
94-
- articles/wrapping-apis
95-
- articles/oauth
96-
92+
- title: Using httr2
93+
navbar: ~
94+
contents:
95+
- articles/wrapping-apis
96+
- articles/oauth
9797

9898
news:
99-
releases:
100-
- text: "httr2 1.0.0"
101-
href: https://www.tidyverse.org/blog/2023/11/httr2-1-0-0/
99+
releases:
100+
- text: "httr2 1.0.0"
101+
href: https://www.tidyverse.org/blog/2023/11/httr2-1-0-0/

man/is_online.Rd

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)