@@ -24,7 +24,7 @@ public class Response {
2424 private final OutputStream BODY ;
2525 private final Headers HEADER ;
2626
27- private MediaType contentType = MediaType ._txt ;
27+ private String contentType = MediaType ._txt . getMIME () ;
2828 private boolean isClose = false ;
2929 private long contentLength = 0 ;
3030 private int status = 200 ;
@@ -112,7 +112,7 @@ public void sendStatus(@NotNull Status status) {
112112 /**
113113 * @return The current contentType
114114 */
115- public MediaType getContentType () {
115+ public String getContentType () {
116116 return contentType ;
117117 }
118118
@@ -122,6 +122,15 @@ public MediaType getContentType() {
122122 * @param contentType - The contentType
123123 */
124124 public void setContentType (MediaType contentType ) {
125+ this .contentType = contentType .getMIME ();
126+ }
127+
128+ /**
129+ * Set the contentType for this response.
130+ *
131+ * @param contentType - The contentType
132+ */
133+ public void setContentType (String contentType ) {
125134 this .contentType = contentType ;
126135 }
127136
@@ -164,7 +173,9 @@ public void send(String s) {
164173 public void send (@ NotNull File file ) {
165174 if (checkIfClosed ()) return ;
166175 this .contentLength += file .length ();
167- this .contentType = Utils .getContentType (file );
176+
177+ MediaType mediaType = Utils .getContentType (file );
178+ this .contentType = mediaType == null ? null : mediaType .getMIME ();
168179 sendHeaders ();
169180
170181 try {
@@ -197,7 +208,7 @@ private void sendHeaders() {
197208 try {
198209
199210 // Fallback
200- String contentType = getContentType (). getExtension () == null ? MediaType ._bin .getExtension () : getContentType (). getMIME ();
211+ String contentType = getContentType () == null ? MediaType ._bin .getExtension () : getContentType ();
201212
202213 // Set header and send response
203214 this .HEADER .set ("Content-Type" , contentType );
0 commit comments