Limit the bandwidth through the proxy on the port associated with proxy argument.

limitBandwidth(proxy, downK = NULL, upK = NULL, downMaxK = NULL,
  upMaxK = NULL, latency = NULL, ...)

Arguments

proxy
An object of class "proxy". A proxy object see proxy.
downK
Sets the downstream bandwidth limit in kbps. Optional if NULL (default) unlimited. From the perspective of the server.
upK
Sets the upstream bandwidth limit kbps. Optional if NULL (default) unlimited. From the perspective of the server.
downMaxK
Specifies how many kilobytes in total the client is allowed to download through the proxy. Optional if NULL (default) unlimited. From the perspective of the server.
upMaxK
Specifies how many kilobytes in total the client is allowed to upload through the proxy. Optional if NULL (default) unlimited. From the perspective of the server.
latency
Add the given latency to each HTTP request. Optional, by default all requests are invoked without latency.
...
Additonal function arguments

Value

invisible(proxy): An object of class "proxy" is invisibly returned. A proxy object see proxy. This allows for chaining from this function to other functions that take such an object as an argument. See examples for further details.

See also

Other bandwidth functions: getBWremaining

Examples

## Not run: ------------------------------------ # library(httr) # # A BMP server is assummed running on port 9090 # prxy <- proxy(bmpPort = 9090L, port = 39500L) # tmp <- tempfile(fileext = ".dat") # prxy %>% createHAR(ref = "httr_download_1") # # # http://ping.online.net/1Mo.dat a 1mb test file # # limit bandwidth to 50kps # prxy %>% limitBandwidth(upK = 200L) # testDL1 <- GET("http://ping.online.net/1Mo.dat", httr_proxy(prxy), # httr::write_disk(tmp, overwrite = TRUE), # config(fresh_connect = 1L)) # # bwDL1 <- prxy %>% getBWremaining() # # create new page # prxy %>% newPage(ref = "httr_download_2") # prxy %>% limitBandwidth(upK = 100L) # # # empty the DNS cache # prxy %>% emptyDNS # testDL2 <- GET("http://ping.online.net/1Mo.dat", httr_proxy(prxy), # httr::write_disk(tmp, overwrite = TRUE), # config(fresh_connect = 1L)) # bwDL2 <- prxy %>% getBWremaining() # # testDL1$times["total"] # testDL2$times["total"] # # prxy %>% closeProxy # # prxy <- proxy(bmpPort = 9090L, port = 39500L) # tmpFile <- upload_file(tmp) # # # create new HAR for uploads # prxy %>% createHAR(ref = "httr_upload_1") # prxy %>% limitBandwidth(downK = 50L) # testUP1 <- POST("http://httpbin.org/post", httr_proxy(prxy), # body = tmpFile, # config(fresh_connect = 1L)) # # create new page # prxy %>% newPage(ref = "httr_upnload_2") # prxy %>% limitBandwidth(downK = 25L) # # # empty the DNS cache # prxy %>% emptyDNS # testUP2 <- POST("http://httpbin.org/post", httr_proxy(prxy), # body = tmpFile, # config(fresh_connect = 1L)) # # testUP1$times["total"] # testUP2$times["total"] # # prxy %>% closeProxy ## ---------------------------------------------