nopasaran.primitives.action_primitives.http_1_response_primitives.HTTP1ResponsePrimitives

class nopasaran.primitives.action_primitives.http_1_response_primitives.HTTP1ResponsePrimitives

Bases: object

Class containing HTTP server action primitives for the state machine.

__init__()

Methods

__init__()

add_http_1_route(inputs, outputs, state_machine)

Add a route to the HTTP server.

close_http_1_server(inputs, outputs, ...)

Close the HTTP server.

create_http_1_server(inputs, outputs, ...)

Create an instance of HTTP1SocketServer.

receive_http_1_requests(inputs, outputs, ...)

Receive HTTP/1.1 requests.

start_http_1_server(inputs, outputs, ...)

Start the HTTP server.

wait_for_http_1_request(inputs, outputs, ...)

Wait for an HTTP request.

static add_http_1_route(inputs, outputs, state_machine)

Add a route to the HTTP server.

Number of input arguments: 2
  • The HTTP1SocketServer instance

  • The dictionary or list with route parameters

Number of output arguments: 0

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

  • The name of the variable containing the dictionary or list with route parameters.

outputs (List[str]): The list of output variable names. No output arguments for this method.

state_machine: The state machine object.

Returns:

None

static close_http_1_server(inputs, outputs, state_machine)

Close the HTTP server.

Number of input arguments: 1
  • The HTTP1SocketServer instance

Number of output arguments: 1
  • The event name

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

outputs (List[str]): The list of output variable names. It contains two output arguments:
  • The name of the variable to store the event name.

state_machine: The state machine object.

static create_http_1_server(inputs, outputs, state_machine)

Create an instance of HTTP1SocketServer.

Number of input arguments: 0

Number of output arguments: 1
  • The created HTTP1SocketServer instance

Args:

inputs (List[str]): The list of input variable names. No input arguments for this method.

outputs (List[str]): The list of output variable names. It contains one output argument:
  • The name of the variable to store the HTTP1SocketServer instance.

state_machine: The state machine object.

Returns:

None

static receive_http_1_requests(inputs, outputs, state_machine)

Receive HTTP/1.1 requests.

Number of input arguments: 1
  • The HTTP1SocketServer instance

Number of output arguments: 2
  • The event name

  • The message

  • The received data

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

outputs (List[str]): The list of output variable names. It contains two output arguments:
  • The name of the variable to store the event name.

  • The name of the variable to store the message.

  • The name of the variable to store the received data.

state_machine: The state machine object.

static start_http_1_server(inputs, outputs, state_machine)

Start the HTTP server.

Number of input arguments: 3
  • The HTTP1SocketServer instance

  • The host to run the server on.

  • The port to run the server on.

Number of output arguments: 2
  • The event name

  • The message

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

  • The name of the variable containing the host.

  • The name of the variable containing the port.

outputs (List[str]): The list of output variable names. It contains two output arguments:
  • The name of the variable to store the event name.

  • The name of the variable to store the message.

state_machine: The state machine object.

static wait_for_http_1_request(inputs, outputs, state_machine)

Wait for an HTTP request.

Number of input arguments: 3
  • The HTTP1SocketServer instance

  • The port to run the server on.

  • The timeout duration in seconds.

Number of output arguments: 1
  • The received request data or None if a timeout occurs.

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

  • The name of the variable containing the port.

  • The name of the variable containing the timeout duration.

outputs (List[str]): The list of output variable names. It contains one output argument:
  • The name of the variable to store the received request data.

state_machine: The state machine object.

Returns:

None