File: connection-sharing.r

package info (click to toggle)
r-cran-httr 1.4.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 968 kB
  • sloc: sh: 9; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 480 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
test_server <- "http://had.co.nz"

# Create a new handle for every request - no connection sharing
rowMeans(replicate(
  20,
  GET(handle = handle(test_server), path = "index.html")$times
))

test_handle <- handle(test_server)
# Re use the same handle for multiple requests
rowMeans(replicate(
  20,
  GET(handle = test_handle, path = "index.html")$times
))

# With httr, handles are automatically pooled
rowMeans(replicate(
  20,
  GET(test_server, path = "index.html")$times
))