Skip to content

Commit

Permalink
Minimal effort attempt to resolve issue #51
Browse files Browse the repository at this point in the history
Apparently, some clients try to send parameters in the URI. Let's see
whether we can disregard them (they're normally passed as headers with
values later).
  • Loading branch information
systemcrash committed Oct 18, 2021
1 parent 2c88fdc commit f137c39
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ap2-receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,24 @@ class AP2Handler(http.server.BaseHTTPRequestHandler):

def dispatch(self):
"""Dispatch the request to the appropriate handler method."""
print(f'{self.command}: {self.path}')
path = self.path
paramStr = ''
if '?' in self.path:
path = self.path.split('?')[0]
paramStr = self.path.split('?')[1]

print(f'{self.command}: {path}')
print(f'!Dropped parameters: {paramStr}') if paramStr else print('')
print(self.headers)
try:
getattr(self, self.HANDLERS[self.command][self.path])()
# pass additional paramArray:
# getattr(self, self.HANDLERS[self.command][path])(paramArray)
# Note: handle_* signatures need e.g. (self, *args, **kwargs)
getattr(self, self.HANDLERS[self.command][path])()
except KeyError:
self.send_error(
404,
": Method %s Path %s endpoint not implemented" % (self.command, self.path),
": Method %s Path %s endpoint not implemented" % (self.command, path),
)
self.server.hap = None

Expand Down

0 comments on commit f137c39

Please sign in to comment.