# Path: conpot/utils/networking.py
# def str_to_bytes(x):
#     return x if isinstance(x, bytes) else str(x).encode("ascii")


import logging
import time
import random
import os
import http.server
import http.client
import conpot.core as conpot_core
import gevent
from datetime import datetime
from html.parser import HTMLParser
from socketserver import ThreadingMixIn
from lxml import etree
from conpot.utils.networking import str_to_bytes

        trailers = []
        xml_trailers = configuration.xpath(
            '//http/statuscodes/status[@name="' + str(status) + '"]/trailers/*'
        )

        if xml_trailers:

            # retrieve all trailers assigned to this status
            for trailer in xml_trailers:
                trailers.append((trailer.attrib["name"], trailer.text))

        return trailers

    def send_response(self, code, message=None):
        """Send the response header and log the response code.
        This function is overloaded to change the behaviour when
        loggers and sending default headers.
        """

        # replace integrated loggers with conpot logger..
        # self.log_request(code)

        if message is None:
            if code in self.responses:
                message = self.responses[code][0]
            else:
                message = ""

        if self.request_version != "HTTP/0.9":

# Path: conpot/utils/networking.py
# def str_to_bytes(x):
#     return x if isinstance(x, bytes) else str(x).encode("ascii")


# Path: conpot/protocols/http/command_responder.py
import logging
import time
import random
import os
import http.server
import http.client
import conpot.core as conpot_core
import gevent
from datetime import datetime
from html.parser import HTMLParser
from socketserver import ThreadingMixIn
from lxml import etree
from conpot.utils.networking import str_to_bytes


        trailers = []
        xml_trailers = configuration.xpath(
            '//http/statuscodes/status[@name="' + str(status) + '"]/trailers/*'
        )

        if xml_trailers:

            # retrieve all trailers assigned to this status
            for trailer in xml_trailers:
                trailers.append((trailer.attrib["name"], trailer.text))

        return trailers

    def send_response(self, code, message=None):
        """Send the response header and log the response code.
        This function is overloaded to change the behaviour when
        loggers and sending default headers.
        """

        # replace integrated loggers with conpot logger..
        # self.log_request(code)

        if message is None:
            if code in self.responses:
                message = self.responses[code][0]
            else:
                message = ""

        if self.request_version != "HTTP/0.9":

            msg = str_to_bytes(