gsub_response {httptest} | R Documentation |
Find and replace within a 'response' or 'request'
Description
These functions pass their arguments to base::gsub()
in order to find and
replace string patterns (regular expressions) within request
or response
objects. gsub_request()
replaces in the request URL and any request body
fields; gsub_response()
replaces in the response URL, the response body,
and it calls gsub_request()
on the request
object found within the
response
.
Usage
gsub_response(response, pattern, replacement, ...)
gsub_request(request, pattern, replacement, ...)
Arguments
response |
An 'httr' |
pattern |
From |
replacement |
A replacement for the matched pattern, possibly including
regular expression backreferences. Passed to |
... |
Additional logical arguments passed to |
request |
An 'httr' |
Details
Note that, unlike gsub()
, the first argument of the function is request
or response
,
not pattern
, while the equivalent argument in gsub()
, "x
", is placed
third. This difference is to maintain consistency with the other redactor
functions in httptest
, which all take response
as the first argument.
Value
A request
or response
object, same as was passed in, with the
pattern replaced in the URLs and bodies.