I’m trying to get up to speed on http in R, specifically using the httr and curl packages
Question1: in httr or curl, is there a way to view the request object itself, independent of it being sent/made/executed? It would be nice to be able to do so in order to better understand what is happening under the hood.
More specific question motivating the above:
Are the following two code block examples doing identical things?
##Block 1 x <- httr::POST(url = "http://httpbin.org/post", body = "foo", content_type("application/json")) #result 1 cat(rawToChar(x$content)) ##Block 2 h <- curl::new_handle() curl::handle_setopt(h, copypostfields = "foo") curl::handle_setheaders(h, "Content-Type" = "application/json") y <- curl::curl_fetch_memory("http://httpbin.org/post", handle = h) #result 2 cat(rawToChar(y$content))
Thank you in advance for any guidance.