http: higher level error wrappers

Description Usage Arguments behavior parameter options using package curl Note See Also Examples

View source: R/s3-classes.R

Description

higher level error wrappers

Usage

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
http100(response, behavior = "auto", message_template, muffle = FALSE)

http101(response, behavior = "auto", message_template, muffle = FALSE)

http102(response, behavior = "auto", message_template, muffle = FALSE)

http200(response, behavior = "auto", message_template, muffle = FALSE)

http201(response, behavior = "auto", message_template, muffle = FALSE)

http202(response, behavior = "auto", message_template, muffle = FALSE)

http203(response, behavior = "auto", message_template, muffle = FALSE)

http204(response, behavior = "auto", message_template, muffle = FALSE)

http205(response, behavior = "auto", message_template, muffle = FALSE)

http206(response, behavior = "auto", message_template, muffle = FALSE)

http207(response, behavior = "auto", message_template, muffle = FALSE)

http208(response, behavior = "auto", message_template, muffle = FALSE)

http226(response, behavior = "auto", message_template, muffle = FALSE)

http300(response, behavior = "auto", message_template, muffle = FALSE)

http301(response, behavior = "auto", message_template, muffle = FALSE)

http302(response, behavior = "auto", message_template, muffle = FALSE)

http303(response, behavior = "auto", message_template, muffle = FALSE)

http304(response, behavior = "auto", message_template, muffle = FALSE)

http305(response, behavior = "auto", message_template, muffle = FALSE)

http306(response, behavior = "auto", message_template, muffle = FALSE)

http307(response, behavior = "auto", message_template, muffle = FALSE)

http308(response, behavior = "auto", message_template, muffle = FALSE)

http400(response, behavior = "auto", message_template, muffle = FALSE)

http401(response, behavior = "auto", message_template, muffle = FALSE)

http402(response, behavior = "auto", message_template, muffle = FALSE)

http403(response, behavior = "auto", message_template, muffle = FALSE)

http404(response, behavior = "auto", message_template, muffle = FALSE)

http405(response, behavior = "auto", message_template, muffle = FALSE)

http406(response, behavior = "auto", message_template, muffle = FALSE)

http407(response, behavior = "auto", message_template, muffle = FALSE)

http408(response, behavior = "auto", message_template, muffle = FALSE)

http409(response, behavior = "auto", message_template, muffle = FALSE)

http410(response, behavior = "auto", message_template, muffle = FALSE)

http411(response, behavior = "auto", message_template, muffle = FALSE)

http412(response, behavior = "auto", message_template, muffle = FALSE)

http413(response, behavior = "auto", message_template, muffle = FALSE)

http414(response, behavior = "auto", message_template, muffle = FALSE)

http415(response, behavior = "auto", message_template, muffle = FALSE)

http416(response, behavior = "auto", message_template, muffle = FALSE)

http417(response, behavior = "auto", message_template, muffle = FALSE)

http418(response, behavior = "auto", message_template, muffle = FALSE)

http419(response, behavior = "auto", message_template, muffle = FALSE)

http420(response, behavior = "auto", message_template, muffle = FALSE)

http422(response, behavior = "auto", message_template, muffle = FALSE)

http423(response, behavior = "auto", message_template, muffle = FALSE)

http424(response, behavior = "auto", message_template, muffle = FALSE)

http425(response, behavior = "auto", message_template, muffle = FALSE)

http426(response, behavior = "auto", message_template, muffle = FALSE)

http428(response, behavior = "auto", message_template, muffle = FALSE)

http429(response, behavior = "auto", message_template, muffle = FALSE)

http431(response, behavior = "auto", message_template, muffle = FALSE)

http440(response, behavior = "auto", message_template, muffle = FALSE)

http444(response, behavior = "auto", message_template, muffle = FALSE)

http449(response, behavior = "auto", message_template, muffle = FALSE)

http450(response, behavior = "auto", message_template, muffle = FALSE)

http451(response, behavior = "auto", message_template, muffle = FALSE)

http494(response, behavior = "auto", message_template, muffle = FALSE)

http495(response, behavior = "auto", message_template, muffle = FALSE)

http496(response, behavior = "auto", message_template, muffle = FALSE)

http497(response, behavior = "auto", message_template, muffle = FALSE)

http498(response, behavior = "auto", message_template, muffle = FALSE)

http499(response, behavior = "auto", message_template, muffle = FALSE)

http500(response, behavior = "auto", message_template, muffle = FALSE)

http501(response, behavior = "auto", message_template, muffle = FALSE)

http502(response, behavior = "auto", message_template, muffle = FALSE)

http503(response, behavior = "auto", message_template, muffle = FALSE)

http504(response, behavior = "auto", message_template, muffle = FALSE)

http505(response, behavior = "auto", message_template, muffle = FALSE)

http506(response, behavior = "auto", message_template, muffle = FALSE)

http507(response, behavior = "auto", message_template, muffle = FALSE)

http508(response, behavior = "auto", message_template, muffle = FALSE)

http509(response, behavior = "auto", message_template, muffle = FALSE)

http510(response, behavior = "auto", message_template, muffle = FALSE)

http511(response, behavior = "auto", message_template, muffle = FALSE)

http598(response, behavior = "auto", message_template, muffle = FALSE)

http599(response, behavior = "auto", message_template, muffle = FALSE)

http(response, behavior = "auto", message_template, muffle = FALSE)

Arguments

response

The result of a call via crul, curl, or httr

behavior

Behavior of the error. default: auto. See Details

message_template

A message template. optional. use whisker templating. names to use are: reason and status. use in template like {{reason}} and {{status}}. Note that {{message}} that is used in message_template_verbose will be ignored here.

muffle

(logical) whether to not respond when status codes in 1xx-3xx series. Default: FALSE

behavior parameter options

Of course, you can always override the defaults.

using package curl

curl reponses are simple lists, so we have little to go on to make sure it's a response from the curl package. We check for list names internally but of course you could pass in a list with the right named elements, while the values are complete nonsense, in which case we'll probably fail badly. There's not much we can do.

Note

These http* methods only use $do and not $do_verbose.

See Also

Error, Error-Classes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
if (requireNamespace("crul")) {
 library("crul")
 res <- HttpClient$new("https://httpbin.org/status/418")$get()
 ## Not run: http(res)
 http(res, behavior = "warning")
 http(res, behavior = "message")

 res <- HttpClient$new("https://httpbin.org/status/414")$get()
 ## Not run: http414(res)
 http(res, behavior = "warning")
 http(res, behavior = "message")

 res <- HttpClient$new("https://httpbin.org/asdfafadsf")$get()
 ## Not run: http404(res)
 http(res, behavior = "warning")
 http(res, behavior = "message")
}

if (requireNamespace("curl")) {
 library("curl")
 h <- curl::new_handle()
 curl::handle_setopt(h)
 res <- curl::curl_fetch_memory("https://httpbin.org/status/418", h)
 ## Not run: http(res)
 http(res, behavior = "warning")
 http(res, behavior = "message")
}

if (requireNamespace("httr")) {
 library("httr")
 res <- GET("https://httpbin.org/status/418")
 ## Not run: http(res)
 http(res, behavior = "warning")
 http(res, behavior = "message")
}

# muffle responses
if (requireNamespace("crul")) {
 library("crul")
 res201 <- HttpClient$new("https://httpbin.org")$get("status/201")
 res404 <- HttpClient$new("https://httpbin.org")$get("status/404")
 # status codes < 300 CAN be muffled - i.e., return the http response object
 http(res201, muffle = TRUE)
 # status codes > 300 CAN NOT be muffled - i.e., return the http response object
 ## Not run: 
 http(res404, muffle = TRUE)
 
## End(Not run)
}

fauxpas documentation built on April 14, 2020, 7:16 p.m.