dont include port in the host section of the reuqest

This commit is contained in:
Hedy Li 2021-07-26 13:29:50 +08:00
parent d6baf888f1
commit 5fcce53a23
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "spartan-py"
version = "0.2.7"
version = "0.2.8"
description = "Library for spartan protocol"
authors = ["Hedy Li <hedy@tilde.cafe>"]
packages = [

View File

@ -13,14 +13,14 @@ class Request:
self.data = data
def __repr__(self):
return f"<Request {self.host}:{self.port} {self.path} {len(self.data)}>"
return f"<Request {self.host} (port {self.port}) {self.path} {len(self.data)}>"
def __str__(self):
return f"{self.host}:{self.port} {self.path} {len(self.data)}"
return f"{self.host} {self.path} {len(self.data)}"
def send(self):
sock = socket.create_connection((self.host, self.port))
host = f"{self.host}:{self.port}".encode("idna")
host = f"{self.host}".encode("idna")
path = self.path.encode("ascii")
sock.send(b"%s %s %d\r\n" % (host, path, len(self.data)))
sock.send(self.data.encode("ascii"))