Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion morgan/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import pathlib
import re
import shutil
import urllib.parse
from typing import Any

Expand Down Expand Up @@ -201,8 +202,12 @@ def _serve_file(self, project, filename):

self.send_response(200)
self.send_header("Content-Type", ct)
self.send_header("Content-Length", str(path.stat().st_size))
self.end_headers()
self.wfile.write(path.read_bytes())
# stream the file instead of reading it into memory, package
# distributions can be several gigabytes in size
with path.open("rb") as fh:
shutil.copyfileobj(fh, self.wfile)


def run(
Expand Down