Skip to content

Commit

Permalink
force lowercase headers and force uppercase method (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyJhb authored May 2, 2024
1 parent d067b98 commit b4393ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tinyweb/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def read_headers(self, save_headers=[]):
frags = line.split(b':', 1)
if len(frags) != 2:
raise HTTPException(400)
if frags[0] in save_headers:
if frags[0].lower() in save_headers:
self.headers[frags[0]] = frags[1].strip()

async def read_parse_form_data(self):
Expand Down Expand Up @@ -528,8 +528,8 @@ def add_route(self, url, f, **kwargs):
params.update(kwargs)
params['allowed_access_control_methods'] = ', '.join(params['methods'])
# Convert methods/headers to bytestring
params['methods'] = [x.encode() for x in params['methods']]
params['save_headers'] = [x.encode() for x in params['save_headers']]
params['methods'] = [x.encode().upper() for x in params['methods']]
params['save_headers'] = [x.encode().lower() for x in params['save_headers']]
# If URL has a parameter
if url.endswith('>'):
idx = url.rfind('<')
Expand Down

0 comments on commit b4393ac

Please sign in to comment.