diff options
Diffstat (limited to 'tests/negtelnetserver.py')
-rwxr-xr-x | tests/negtelnetserver.py | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/tests/negtelnetserver.py b/tests/negtelnetserver.py index f2f2ab500..1efc64b56 100755 --- a/tests/negtelnetserver.py +++ b/tests/negtelnetserver.py @@ -1,6 +1,24 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 2017 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.haxx.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# """ A telnet server which negotiates""" from __future__ import (absolute_import, division, print_function, @@ -9,11 +27,10 @@ import argparse import os import sys import logging -try: # Python 2 - import SocketServer as socketserver -except ImportError: # Python 3 +if sys.version_info.major >= 3: import socketserver - +else: + import SocketServer as socketserver log = logging.getLogger(__name__) HOST = "localhost" @@ -67,13 +84,13 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler): data = neg.recv(1024) log.debug("Incoming data: %r", data) - if VERIFIED_REQ.encode('ascii') in data: + if VERIFIED_REQ.encode('utf-8') in data: log.debug("Received verification request from test framework") response = VERIFIED_RSP.format(pid=os.getpid()) - response_data = response.encode('ascii') + response_data = response.encode('utf-8') else: log.debug("Received normal request - echoing back") - response_data = data.strip() + response_data = data.decode('utf-8').strip().encode('utf-8') if response_data: log.debug("Sending %r", response_data) |