~hedy/spartan-py

5fcce53a2358124659d8b34a8ea1366f6dc3f354 — Hedy Li 2 years ago d6baf88 v0.2.8
dont include port in the host section of the reuqest
2 files changed, 4 insertions(+), 4 deletions(-)

M pyproject.toml
M spartan/request.py
M pyproject.toml => pyproject.toml +1 -1
@@ 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 = [

M spartan/request.py => spartan/request.py +3 -3
@@ 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"))