Skip to content

This is the most general way of processing the response from the server - you receive the raw bytes as they come in, and you can do whatever you want with them.

Usage

write_stream(f)

Arguments

f

Callback function. It should have a single argument, a raw vector containing the bytes recieved from the server. This will usually be 16k or less. The return value of the function is ignored.

Examples

GET(
  "https://github.com/jeroen/data/raw/gh-pages/diamonds.json",
  write_stream(function(x) {
    print(length(x))
    length(x)
  })
)
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32764
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 13609
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 21593
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 9983
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 10037
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 12022
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 12286
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 13751
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 24257
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 10450
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 26715
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 5033
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 31736
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32768
#> [1] 32183
#> Response [https://raw.githubusercontent.com/jeroen/data/gh-pages/diamonds.json]
#>   Date: 2026-02-13 21:42
#>   Status: 200
#>   Content-Type: text/plain; charset=utf-8
#> <EMPTY BODY>