Executes the javascript against each request

reqInterceptor(proxy, jsFilter, ...)

Arguments

proxy
An object of class "proxy". A proxy object see proxy.
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

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 intercept functions: resInterceptor

Examples

## 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 ## ---------------------------------------------