Skip to content

Commit

Permalink
incorrect slicing
Browse files Browse the repository at this point in the history
and some var name cleanup
  • Loading branch information
mnot committed Aug 25, 2023
1 parent 45a8803 commit 05724ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bin/redbot_cgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def out(inbytes: bytes) -> None:
req_hdrs: RawHeaderListType = []
for key, val in os.environ.items():
if key[:5] == "HTTP_":
req_hdrs.append((key[:5].lower().encode("ascii"), val.encode("ascii")))
req_hdrs.append((key[5:].lower().encode("ascii"), val.encode("ascii")))
req_body = sys.stdin.read().encode("utf-8")

class Exchange(HttpResponseExchange):
Expand All @@ -54,11 +54,11 @@ def response_start(
out(b"\n".join(out_v))

def response_body(self, chunk: bytes) -> None:
freak_ceiling = 20000
ceiling = 20000
rest = None
if len(chunk) > freak_ceiling:
rest = chunk[freak_ceiling:]
chunk = chunk[:freak_ceiling]
if len(chunk) > ceiling:
rest = chunk[ceiling:]
chunk = chunk[:ceiling]
out(chunk)
if rest:
self.response_body(rest)
Expand Down

0 comments on commit 05724ce

Please sign in to comment.