#326 util/log: Convert properly between str and bytearray
Merged 3 years ago by simo. Opened 3 years ago by ngompa.
ngompa/ipsilon fix-logger-py3  into  master

file modified
+3 -3
@@ -179,7 +179,7 @@ 

          f = StringIO()

  

          for chunk in body:

-             f.write(chunk)

+             f.write(chunk.decode('utf-8'))

  

          string = f.getvalue()

          f.close()
@@ -244,9 +244,9 @@ 

      if response.stream:

          f.write(indent_text("body omitted because response is streaming\n", 2))

      else:

-         response.body = collapse_body(response.body)

+         response.body = collapse_body(response.body).encode('utf-8')

          for chunk in response.body:

-             f.write(indent_text(chunk, 2))

+             f.write(indent_text(chunk.decode('utf-8'), 2))

  

      string = f.getvalue()

      f.close()

Most of this file operates on strings, but there are a couple
of places operating on bytes, and we need to handle switching
back and forth between the two types in this case.

Signed-off-by: Neal Gompa ngompa13@gmail.com

This seems to fix response logging, but there's still this funkiness...

[Mon Apr 27 03:13:23.757866 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]     Headers:
[Mon Apr 27 03:13:23.757999 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Content-Type': b'text/html;charset=utf-8'
[Mon Apr 27 03:13:23.758009 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Server': b'CherryPy/18.4.0'
[Mon Apr 27 03:13:23.758014 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Date': b'Mon, 27 Apr 2020 01:13:23 GMT'
[Mon Apr 27 03:13:23.758099 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Cache-Control': b'no-cache, no-store, must-revalidate, private'
[Mon Apr 27 03:13:23.758108 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Pragma': b'no-cache'
[Mon Apr 27 03:13:23.758237 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Content-Security-Policy': b"frame-ancestors 'none'"
[Mon Apr 27 03:13:23.758247 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'X-Frame-Options': b'deny'
[Mon Apr 27 03:13:23.758373 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'X-XRDS-Location': b'https://sso.opensuse.org/openid/XRDS'
[Mon Apr 27 03:13:23.758380 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Content-Length': b'1846'
[Mon Apr 27 03:13:23.758385 2020] [wsgi:error] [pid 49765:tid 140321971894016] [remote 192.168.47.101:40266]         b'Set-Cookie': b'root_ipsilon_session_id=<redacted>; expires=Mon, 27 Apr 2020 01:43:23 GMT; HttpOnly; Max-Age=1800; Path=/; Secure'

Pull-Request has been merged by simo

3 years ago
Metadata