Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes issue with header with no space #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import socket
import sys
import re

# Block size is set to 8192 because thats usually the max header size
BLOCK_SIZE = 8192
Expand Down Expand Up @@ -64,8 +65,10 @@ def build_request(first_chunk):
lines = first_chunk.decode('utf-8', 'ignore').split('\r\n')
h = {'request-line': lines[0]}
i = 1
header_kv = re.compile('(\w\S+)\s?:\s?(\S.*)')
while i < len(lines[1:]) and lines[i] != '':
k, v = lines[i].split(': ')
m = header_kv.match(lines[i])
k, v = m.group(1), m.group(2)
h.update({k.lower(): v})
i += 1
r = {
Expand Down