Skip to content
Daniele Linguaglossa edited this page Jan 8, 2018 · 2 revisions

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.

Methods

Below the list of methods:

httpToString

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

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

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

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

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

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)
}

Parameter

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)

Related Topics

Clone this wiki locally