This handle preserves settings and cookies across multiple requests. It is the foundation of all requests performed through the httr package, although it will mostly be hidden from the user.

handle(url, cookies = TRUE)

Arguments

url

full url to site

cookies

DEPRECATED

Note

Because of the way argument dispatch works in R, using handle() in the http methods (See GET) will cause problems when trying to pass configuration arguments (See examples below). Directly specifying the handle when using http methods is not recommended in general, since the selection of the correct handle is taken care of when the user passes an url (See handle_pool).

Examples

handle("http://google.com")
#> Host: http://google.com <NA>
handle("https://google.com")
#> Host: https://google.com <NA>
h <- handle("http://google.com") GET(handle = h)
#> Response [http://www.google.com/] #> Date: 2017-08-16 14:12 #> Status: 200 #> Content-Type: text/html; charset=ISO-8859-1 #> Size: 10.4 kB #> <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="... #> </style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;over... #> if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.fo... #> } #> })();</script><div id="mngb"> <div id=gbar><nobr><b class=gb1>Search</b> <a c...
# Should see cookies sent back to server GET(handle = h, config = verbose())
#> Response [http://www.google.com/] #> Date: 2017-08-16 14:12 #> Status: 200 #> Content-Type: text/html; charset=ISO-8859-1 #> Size: 10.4 kB #> <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="... #> </style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;over... #> if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.fo... #> } #> })();</script><div id="mngb"> <div id=gbar><nobr><b class=gb1>Search</b> <a c...
h <- handle("http://google.com", cookies = FALSE)
#> Warning: Cookies argument is depcrated
GET(handle = h)$cookies
#> domain flag path secure expiration name #> 1 #HttpOnly_.google.com TRUE / FALSE 2018-02-15 08:12:20 NID #> value #> 1 110=OcHsKvj-zDz9gYfwDawnbJJ5HMRBzmpAR05lLiW6LP40w4PzYAJ_StQQ_ql9O0uxz7XPNr65MDfUdqISLnUnMUPAmyj_bpf56fc7AVtXAHaKbDkO6YJQHTWaC3rKKsxr
# NOT RUN { # Using the preferred way of configuring the http methods # will not work when using handle(): GET(handle = h, timeout(10)) # Passing named arguments will work properly: GET(handle = h, config = list(timeout(10), add_headers(Accept = ""))) # }