From 6aa63d90442ed9fcfdab7e98b1c8e0879768ce73 Mon Sep 17 00:00:00 2001 From: Bigchrome Date: Sat, 4 Jun 2016 22:49:24 +0100 Subject: [PATCH] Adds ability to serve .css with text/css content-type --- .../matlab/functions/make_css_http_header.m | 14 ++++++++++++++ pymatbridge/matlab/webserver.m | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 pymatbridge/matlab/functions/make_css_http_header.m diff --git a/pymatbridge/matlab/functions/make_css_http_header.m b/pymatbridge/matlab/functions/make_css_http_header.m new file mode 100644 index 0000000..d238200 --- /dev/null +++ b/pymatbridge/matlab/functions/make_css_http_header.m @@ -0,0 +1,14 @@ +function header=make_css_http_header(html,found) +if(found) + header.HTTP='200 OK'; +else + header.HTTP='404 Not Found'; +end +header.Date='Tue, 12 May 2016 09:19:05 GMT'; +header.Server='Matlab Webserver'; +header.LastModified='Last-Modified: Tue, 12 May 2016 09:19:05 GMT'; +header.AcceptRanges='Accept-Ranges: bytes'; +header.ContentLength=num2str(length(html)); +header.ETag='"948921-15ae-c0dbf340"'; +%header.KeepAlive='Keep-Alive: timeout=15, max=100'; +header.ContentType='text/css'; diff --git a/pymatbridge/matlab/webserver.m b/pymatbridge/matlab/webserver.m index c29c0ab..f6e7378 100644 --- a/pymatbridge/matlab/webserver.m +++ b/pymatbridge/matlab/webserver.m @@ -137,6 +137,12 @@ function webserver(port,config) fclose(fid); header=make_image_http_header(html,found); response=header2text(header); + case {'.css'} + fid = fopen(fullfilename, 'r'); + html = fread(fid, inf, 'int8')'; + fclose(fid); + header=make_css_http_header(html,found); + response=header2text(header); otherwise fid = fopen(fullfilename, 'r'); html = fread(fid, inf, 'int8')';