Skip to content

Commit

Permalink
fix http directory listing
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 3, 2024
1 parent bb8db97 commit 3aa22cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions xpra/net/http/directory_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

# duplicated form SimpleHTTPRequestHandler
# duplicated from SimpleHTTPRequestHandler
# so that we can re-use it from the quic handler
# and also so that we can customize it more easily

Expand Down Expand Up @@ -52,8 +52,9 @@ def list_directory(path:str):
encoded = '\n'.join(r).encode(enc, 'surrogateescape')
f = BytesIO()
f.write(encoded)
f.seek(0)
contents = f.getvalue()
f.close()
return 200, {
"Content-type", f"text/html; charset={enc}",
"Content-Length", str(len(encoded)),
}, f
"Content-type": f"text/html; charset={enc}",
"Content-Length": str(len(encoded)),
}, contents
7 changes: 5 additions & 2 deletions xpra/net/http/http_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,11 @@ def send_head(self):
if not self.directory_listing:
self.send_error(403, "Directory listing forbidden")
return None
return list_directory(path).read()

code, headers, body = list_directory(path)
self.send_response(code)
self.extra_headers.update(headers)
self.end_headers()
return body
try:
code, extra_headers, content = load_path(self.headers, path)
lm = extra_headers.get("Last-Modified")
Expand Down

0 comments on commit 3aa22cf

Please sign in to comment.