forked from nat/sludge
fix error with response type being passed as response.body; omit requests originating form status.natalieee.net from the log
This commit is contained in:
parent
2661e44e78
commit
cf2fa1f0c0
@ -104,7 +104,7 @@ patchers: List[Patcher] = [
|
||||
lambda response, request: Response(
|
||||
response.code,
|
||||
response.headers,
|
||||
re.sub(r'sludge', lambda match: 'sludge' + ' (/slʌd͡ʒ/)' if random.randint(0, 5) < 1 else 'sludge', response.body.decode('utf-8')).encode('utf-8')
|
||||
re.sub(r'sludge', lambda match: 'sludge' + ' (/slʌd͡ʒ/)' if random.randint(0, 5) < 1 else 'sludge', response.body.decode()).encode('utf-8')
|
||||
) if 'text/html' in response.headers.values() else response,
|
||||
lambda response, request: Response(
|
||||
response.code,
|
||||
|
@ -44,7 +44,9 @@ class Request:
|
||||
body_start = request_str.find('\r\n\r\n') + 4
|
||||
body = Body(request_bytes[body_start:], headers.get('Content-Type') or 'text/plain')
|
||||
|
||||
log.info(f'received request for {path.path} from {headers.get('X-Real-IP')}')
|
||||
if not 'Nim httpclient' in headers.get('user-agent'):
|
||||
log.info(f'received request for {path.path} from {headers.get('X-Real-IP')}')
|
||||
|
||||
return cls(method, path, version, headers, body)
|
||||
|
||||
def match(self):
|
||||
|
@ -52,7 +52,7 @@ routes = [
|
||||
lambda request, *_: Response(
|
||||
ResponseCode.OK,
|
||||
{'Content-Type': 'text/html'},
|
||||
((parse_file('./home.html', dict(prev='\\/')).encode('utf-8') if not 'Nim httpclient' in request.headers.get('user-agent') else error_page(200)) if request.method == Method.GET else (
|
||||
((parse_file('./home.html', dict(prev='\\/')).encode('utf-8') if not 'Nim httpclient' in request.headers.get('user-agent') else error_page(200).body) if request.method == Method.GET else (
|
||||
[
|
||||
(lambda form_data: (
|
||||
(lambda time: (
|
||||
|
@ -25,7 +25,7 @@ def handle_client(client: socket.socket, addr: Tuple[str, int]) -> None:
|
||||
.execute(request, client, addr) \
|
||||
.send(client)
|
||||
|
||||
log.info('destroy thread')
|
||||
log.debug('destroy thread')
|
||||
|
||||
def main() -> None:
|
||||
http_thread = threading.Thread(name='http', target=serve, args=('0.0.0.0', config['http-port'], handle_client))
|
||||
|
Loading…
Reference in New Issue
Block a user