Description Usage Arguments Value See Also Examples
Executes the javascript against each response
1 | resInterceptor(proxy, jsFilter, ...)
|
proxy |
An object of class "proxy". A proxy object see
|
jsFilter |
Javascript response filters have access to the variables response (type io.netty.handler.codec.http.HttpResponse), contents (type net.lightbody.bmp.util.HttpMessageContents), and messageInfo (type net.lightbody.bmp.util.HttpMessageInfo). As in the request filter, messageInfo contains additional information about the message. |
... |
Additonal function arguments |
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.
Other intercept functions: reqInterceptor
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 | ## Not run:
library(httr)
library(xml2)
# A BMP server is assummed running on port 9090
prxy <- proxy(bmpPort = 9090L, port = 39500L)
# filter request
ua1 <- GET("http://httpbin.org/user-agent", httr_proxy(prxy),
user_agent("httr"))
requestFilter <- "request.headers().remove('User-Agent');
request.headers().add('User-Agent', 'My-Custom-User-Agent-String 1.0');"
prxy %>% reqInterceptor(requestFilter)
ua2 <- GET("http://httpbin.org/user-agent", httr_proxy(prxy),
user_agent("httr"))
content(ua1)
content(ua2)
prxy %>% closeProxy
#filter response
prxy <- proxy(bmpPort = 9090L, port = 39500L)
responseFilter <-
"contents.setTextContents(
'<html><body>Response successfully intercepted</body></html>');"
prxy %>% resInterceptor(responseFilter)
rproj <- GET("http://r-project.org", httr_proxy(prxy))
rproj %>% read_html %>% xml_find_all("//body") %>% xml_text
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.