File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 22
33import com .sun .net .httpserver .Headers ;
44import com .sun .net .httpserver .HttpExchange ;
5+ import express .ExpressUtils ;
56import express .http .cookie .Cookie ;
67
78import java .io .File ;
@@ -93,14 +94,14 @@ public void send(String s) {
9394
9495 /**
9596 * Send an entire file as response
97+ * The mime type will be automatically detected.
9698 *
97- * @param file The file.
98- * @param contentType Content type.
99+ * @param file The file.
99100 */
100- public void send (File file , String contentType ) {
101+ public void send (File file ) {
101102 if (checkIfClosed ()) return ;
102103 this .contentLength += file .length ();
103- this .contentType = contentType ;
104+ this .contentType = ExpressUtils . getContentType ( file ) ;
104105 sendHeaders ();
105106
106107 try {
Original file line number Diff line number Diff line change @@ -34,10 +34,8 @@ public Static(String directoryPath) {
3434 public void handle (Request req , Response res ) {
3535 File reqFile = new File (PATH + req .getURI ().getPath ());
3636
37- if (reqFile .exists ()) {
38- String contentType = ExpressUtils .getContentType (reqFile );
39- res .send (reqFile , contentType );
40- }
37+ if (reqFile .exists ())
38+ res .send (reqFile );
4139 }
4240
4341
You can’t perform that action at this time.
0 commit comments