Skip to content

Commit

Permalink
Code improvement.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iury O. G. Figueiredo committed Nov 1, 2020
1 parent 80e23bc commit 8f3ebbe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@

from distutils.core import setup
setup(name="websnake",
version="2.0.0",
version="2.0.1",
py_modules=['websnake'],
author="Iury O. G. Figueiredo",
author_email="ioliveira@id.uff.br",
Expand Down
13 changes: 2 additions & 11 deletions websnake.py
Expand Up @@ -6,12 +6,12 @@
from untwisted.network import Spin, xmap, spawn, SSL
from untwisted.dispatcher import Dispatcher
from untwisted.event import get_event
from base64 import encodebytes
from untwisted import core
from tempfile import TemporaryFile
from socket import getservbyname
import sys


class Headers(dict):
def __init__(self, data):
for ind in data:
Expand Down Expand Up @@ -196,22 +196,13 @@ def post(addr, payload=b'', version='HTTP/1.1', headers={}, auth=()):
if url.scheme == 'https' else create_con(url.hostname, port, request)

def build_auth(username, password):
from base64 import encodestring

# The headers will be encoded as utf8.
username = username.encode('utf8')
password = password.encode('utf8')

base = encodestring(b'%s:%s' % (username, password))
base = encodebytes(b'%s:%s' % (username, password))
base = base.replace(b'\n', b'').decode('utf8')
return "Basic %s" % base










0 comments on commit 8f3ebbe

Please sign in to comment.