Skip to content

Commit 132d36c

Browse files
committed
Added passing HTTPResponse headers to file response
1 parent e7f0dea commit 132d36c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

adafruit_httpserver/response.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def send(self, conn: Union[SocketPool.Socket, socket.socket]) -> None:
8787
conn,
8888
filename = self.filename,
8989
root_path = self.root_path,
90-
file_length = file_length
90+
file_length = file_length,
91+
headers = self.headers,
9192
)
9293
except OSError:
9394
self._send_response(
@@ -128,14 +129,16 @@ def _send_file_response(
128129
conn: Union[SocketPool.Socket, socket.socket],
129130
filename: str,
130131
root_path: str,
131-
file_length: int
132+
file_length: int,
133+
headers: Dict[str, str] = None
132134
):
133135
self._send_bytes(
134136
conn,
135137
self._construct_response_bytes(
136138
status = self.status,
137139
content_type = MIMEType.from_file_name(filename),
138-
content_length = file_length
140+
content_length = file_length,
141+
headers = headers,
139142
),
140143
)
141144
with open(root_path + filename, "rb") as file:

0 commit comments

Comments
 (0)