getBWremaining: Get bandwidth remaining

Description Usage Arguments Value See Also Examples

Description

Displays the amount of data remaining to be uploaded/downloaded until the limit is reached

Usage

1

Arguments

proxy

An object of class "proxy". A proxy object see proxy.

...

Additonal function arguments

Value

A data.frame detailing the maximum bandwidth and remaining bandwidth upstream and downstream is returned.

See Also

Other bandwidth functions: limitBandwidth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
## 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

## End(Not run)

johndharrison/bmproxy documentation built on May 19, 2019, 5:13 p.m.