Skip to content

Commit 71f8e56

Browse files
committed
Fix Issues With CSS Resource Files ..
1 parent 0e0b9ce commit 71f8e56

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

server/src/main/java/com/androthink/server/handler/ResponseHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,13 @@ public void sendHtmlFileResponse(int code, String filename, @NonNull Map<String,
172172

173173
/**
174174
* @param filename filename for the html file to be sent .
175+
* @param contentType response content type .
175176
* @throws IOException throws exception if response channel closed .
176177
*/
177-
public void sendResourceFileResponse(String filename) throws IOException {
178+
public void sendResourceFileResponse(String filename, String contentType) throws IOException {
178179

179180
BufferedInputStream file = ServerHelper.getResourceFromAsset(context, filename);
180-
sendResponseHeader(ServerHelper.RESPONSE_CODE.OK, ServerHelper.CONTENT_TYPE.HTML, file.available());
181+
sendResponseHeader(ServerHelper.RESPONSE_CODE.OK, contentType, file.available());
181182

182183
int u;
183184
byte[] buffer = new byte[1024];

server/src/main/java/com/androthink/server/helper/ServerHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ public class CONTENT_TYPE {
5858
public static final String FORM_URL_ENCODED_DATA = "application/x-www-form-urlencoded";
5959

6060
public static final String HTML = "text/html";
61+
public static final String CSS = "text/css";
6162
public static final String TEXT = "text/plain";
6263

64+
public static final String TEXT_JAVA_SCRIPT = "text/javascript";
65+
public static final String JAVA_SCRIPT = "application/javascript";
66+
6367
public static final String PNG = "image/png";
6468
public static final String GIF = "image/gif";
6569
public static final String JPEG = "image/jpeg";

0 commit comments

Comments
 (0)