request, responseBody, environment) and change variables through an object called requestly. These still work, so scripts written that way keep running. They are deprecated: for new scripts, use the rq.* API each one points to.
The first time a script uses one of the objects or functions below, the console shows one warning for it that names the rq.* replacement. A script that uses the same name again does not warn again.
Global variables
Each global is set up before your script runs and does not follow later changes.
The response globals exist only when the script has a response, so in a pre-request script they are not defined.
Details
request.headershas lowercase names. A header that appears more than once is an array, and a disabled header is left out.request.datais the raw text of a raw body. For a form body (urlencoded or form-data) it is an object of the parameters, and a parameter that repeats becomes an array. Without a body it is{}.- Changing
request,environmentorglobalschanges only the copy in your script. The request that is sent and the variables you save do not change. To change them, userq.request,rq.environmentandrq.globals. testsis read when the main part of your script has finished. Each key becomes one test that passes when its value is truthy. A key you assign later, for example inside a callback, is not reported.
The requestly object
requestly changes variables and the run order. Every member has a matching rq.* call.
The two response members exist only when the script has a response.
The setters store a value that is truthy as its text, so
requestly.setEnvironmentVariable("count", 5) stores "5". A value that is falsy (0, false, an empty string) is stored as it is. The setters also update the environment and globals copies, so a script that mixes the two reads its own writes.
Libraries
tv4, Backbone and cheerio are also available as globals. They load the first time you use them and warn once. Load them with require('tv4'), require('backbone') and require('cheerio') instead. See Import packages into your scripts.
Where they are not defined
Whether code in a custom package can see these globals orrequestly depends on the script mode, so do not rely on them there. Pass what the package needs as function arguments, or read it through rq.
