-
Notifications
You must be signed in to change notification settings - Fork 61
Utils
Utils as the name implies it's the main utility class and provide the user an easy way to interact with the request and the responses from and to the target.
Below the list of methods:
httpToString
is the method used to convert an http.Request
or http.Response
object to its string representation, below an example:
// Signature
// Utils.httpToString(object request_response)
function test(base_request) {
var request_string = Utils.httpToString(base_request)
}
setParameter
is the method used to modify a parameter inside an http.Request
or http.Response
object, below an example:
// Signature
// Utils.setParameter(parameter param, string value)
function test(base_request) {
// retrieve pluto parameter
var p = Utils.getParameter(base_request, "pluto")
// change value of pluto parameter
Utils.setParameter(pluto, "new-value")
}
getParameter
is the method used to retrieve a parameter from an http.Request
object, below an example:
// Signature
// Utils.getParameter(http.Request req, string parameter_name)
function test(base_request) {
// retrieve pluto parameter
var p = Utils.getParameter(base_request, "pluto")
// get parameter value
var value = p.curValue;
}
getAllParameter
is the method used to retrieve every parameter from an http.Request
object, below an example:
// Signature
// Utils.getAllParameter(http.Request * req)
function test(base_request) {
// Get all parameters
var all_parameters = Utils.getAllParameters(base_request);
// Loop each parameter
for(var i=0; i<all_parameters.length; i++) {
// get parameter value
var value = all_parameters[i].curValue;
}
}
deleteParameter
is the method used to delete a parameter from an http.Request
object, below an example:
// Signature
// Utils.deleteParameter(parameter param)
function test(base_request) {
// retrieve pluto parameter
var p = Utils.getParameter(base_request, "pluto")
// delete parameter from request
Utils.deleteParameter(p)
}
addParameter
is the method used to create a new parameter for an http.Request
object, below an example:
// Signature
// Utils.addParameter(string name, string value, int position, http.Request * req)
function test(base_request) {
// create pluto URL parameter
var p = Utils.addParameter("pluto", "pluto-value", Param.POSITION_URL, base_request)
}
We are talking about parameters but let's better understand how they are handled inside goWAPT.
A parameter is an object related to an http.Request instance it has the following properties:
- request - A reference to its request
- name - The parameter name
- orgValue - The parameter original value (only populated when dynamically changed)
- curValue - The parameter current Value
- position - The parameter position (URL, BODY or HEADER)