Description Usage Arguments Value See Also Examples
Executes the javascript against each request
1 | reqInterceptor(proxy, jsFilter, ...)
|
proxy |
An object of class "proxy". A proxy object see
|
jsFilter |
Javascript request filters have access to the variables request (type io.netty.handler.codec.http.HttpRequest), contents (type net.lightbody.bmp.util.HttpMessageContents), and messageInfo (type net.lightbody.bmp.util.HttpMessageInfo). messageInfo contains additional information about the message, including whether the message is sent over HTTP or HTTPS, as well as the original request received from the client before any changes made by previous filters. If the javascript returns an object of type io.netty.handler.codec.http.HttpResponse, the HTTP request will "short-circuit" and return the response immediately |
... |
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: resInterceptor
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.