Stefan4472 / Stefans-Blog

Personal blogging platform built in Python
MIT License
0 stars 0 forks source link

KeyError: 'HTTP_USER_AGENT' in request.environ #84

Closed Stefan4472 closed 1 year ago

Stefan4472 commented 1 year ago

Server log:

KeyError: 'HTTP_USER_AGENT'
2023-01-07 12:04:43,708: OSError: write error
2023-01-07 12:04:43,892: OSError: write error
2023-01-13 14:36:28,832: OSError: write error
2023-01-13 14:36:29,475: OSError: write error
2023-01-17 19:35:56,388: OSError: write error
2023-01-19 10:15:51,122: Exception on /post/how-to-train-your-robot [HEAD]
Traceback (most recent call last):
  File "/home/skussmaul/.virtualenvs/blogenv/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/skussmaul/.virtualenvs/blogenv/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/skussmaul/.virtualenvs/blogenv/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/skussmaul/.virtualenvs/blogenv/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/skussmaul/.virtualenvs/blogenv/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/skussmaul/.virtualenvs/blogenv/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/skussmaul/Stefans-Blog/flaskr/site_logger.py", line 39, in decorated_function
    log_visit()
  File "/home/skussmaul/Stefans-Blog/flaskr/site_logger.py", line 15, in log_visit
    user_agent = request.environ['HTTP_USER_AGENT']
KeyError: 'HTTP_USER_AGENT'