Skip to content

Commit c69b41c

Browse files
committed
Build header to include content type
for debugging
1 parent b37efc3 commit c69b41c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/server.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,13 @@ where
185185
}
186186
};
187187

188-
let resp = http::Response::builder().status(status).body(()).unwrap();
188+
let mut resp_builder = http::Response::builder();
189+
if req.uri().path().ends_with(".js") {
190+
resp_builder = resp_builder.header(
191+
http::header::CONTENT_TYPE,
192+
http::HeaderValue::from_static("text/javascript; charset=UTF-8"));
193+
}
194+
let resp: http::Response<()> = resp_builder.status(status).body(()).unwrap();
189195

190196
match stream.send_response(resp).await {
191197
Ok(_) => {

0 commit comments

Comments
 (0)