nopasaran.primitives.action_primitives.http_1_request_primitives.HTTP1RequestPrimitives

class nopasaran.primitives.action_primitives.http_1_request_primitives.HTTP1RequestPrimitives

Bases: object

Class containing HTTP/1.1 action primitives for the state machine.

__init__()

Methods

__init__()

add_http_1_request_header(inputs, outputs, ...)

Add a header to an HTTP/1.1 request packet.

add_http_1_request_headers(inputs, outputs, ...)

Add multiple headers to an HTTP/1.1 request packet.

calculate_http_1_request_if_modified_since(...)

Calculate the 'If-Modified-Since' header value for an HTTP/1.1 request packet.

construct_http_1_request_packet(inputs, ...)

Construct an HTTP/1.1 request packet from a dictionary of parameters.

get_body_from_http_1_response(inputs, ...)

Extract the body from an HTTP/1.1 response.

get_header_from_http_1_response(inputs, ...)

Get a header value from an HTTP/1.1 response.

make_http_1_request(inputs, outputs, ...)

Make an HTTP/1.1 request using the request packet.

remove_http_1_request_header(inputs, ...)

Remove a header from an HTTP/1.1 request packet.

remove_http_1_request_headers(inputs, ...)

Remove multiple headers from an HTTP/1.1 request packet.

static add_http_1_request_header(inputs, outputs, state_machine)

Add a header to an HTTP/1.1 request packet.

Number of input arguments: 3
  • The request packet

  • The header name

  • The header value

Number of output arguments: 1
  • The modified request packet

Args:
inputs (List[str]): The list of input variable names. It contains three mandatory input arguments:
  • The name of the variable containing the request packet.

  • The name of the variable containing the header name.

  • The name of the variable containing the header value.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the modified request packet.

state_machine: The state machine object.

Returns:

None

static add_http_1_request_headers(inputs, outputs, state_machine)

Add multiple headers to an HTTP/1.1 request packet.

Number of input arguments: 2
  • The request packet

  • The headers (list of header name-value pairs)

Number of output arguments: 1
  • The modified request packet

Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
  • The name of the variable containing the request packet.

  • The name of the variable containing the headers list.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the modified request packet.

state_machine: The state machine object.

Returns:

None

static calculate_http_1_request_if_modified_since(inputs, outputs, state_machine)

Calculate the ‘If-Modified-Since’ header value for an HTTP/1.1 request packet.

Number of input arguments: 2
  • The request packet

  • The number of seconds ago for the ‘If-Modified-Since’ header

Number of output arguments: 1
  • The modified request packet

Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
  • The name of the variable containing the request packet.

  • The name of the variable containing the number of seconds ago.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the modified request packet.

state_machine: The state machine object.

Returns:

None

static construct_http_1_request_packet(inputs, outputs, state_machine)

Construct an HTTP/1.1 request packet from a dictionary of parameters.

Number of input arguments: 1
  • The dictionary with the request parameters

Number of output arguments: 1
  • The request packet

Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument:
  • The name of the variable containing the dictionary with request parameters.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the constructed request packet.

state_machine: The state machine object.

Returns:

None

static get_body_from_http_1_response(inputs, outputs, state_machine)

Extract the body from an HTTP/1.1 response.

Number of input arguments: 1
  • The HTTP response

Number of output arguments: 1
  • The response body

Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument:
  • The name of the variable containing the HTTP response.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the response body.

state_machine: The state machine object.

Returns:

None

static get_header_from_http_1_response(inputs, outputs, state_machine)

Get a header value from an HTTP/1.1 response.

Number of input arguments: 2
  • The HTTP response

  • The header name

Number of output arguments: 1
  • The header value

Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
  • The name of the variable containing the HTTP response.

  • The name of the variable containing the header name.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the header value.

state_machine: The state machine object.

Returns:

None

static make_http_1_request(inputs, outputs, state_machine)

Make an HTTP/1.1 request using the request packet.

Number of input arguments: 3
  • The request packet

  • The ip address to connect to

  • The port to connect to

Number of output arguments: 1
  • The HTTP response

Args:
inputs (List[str]): The list of input variable names. It contains three mandatory input arguments:
  • The name of the variable containing the request packet.

  • The name of the variable containing the ip address or hostname.

  • The name of the variable containing the port number.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the HTTP response.

state_machine: The state machine object.

Returns:

None

static remove_http_1_request_header(inputs, outputs, state_machine)

Remove a header from an HTTP/1.1 request packet.

Number of input arguments: 2
  • The request packet

  • The header name

Number of output arguments: 1
  • The modified request packet

Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
  • The name of the variable containing the request packet.

  • The name of the variable containing the header name.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the modified request packet.

state_machine: The state machine object.

Returns:

None

static remove_http_1_request_headers(inputs, outputs, state_machine)

Remove multiple headers from an HTTP/1.1 request packet.

Number of input arguments: 2
  • The request packet

  • The headers (list of header names to be removed)

Number of output arguments: 1
  • The modified request packet

Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
  • The name of the variable containing the request packet.

  • The name of the variable containing the list of header names.

outputs (List[str]): The list of output variable names. It contains one mandatory output argument,

which is the name of the variable to store the modified request packet.

state_machine: The state machine object.

Returns:

None