From c33ba75395fc7d6ba62c1ad969be9d5219dbc948 Mon Sep 17 00:00:00 2001 From: Marcos Kirsch Date: Sat, 14 Feb 2015 01:19:38 -0600 Subject: [PATCH] Send files in little chunks, large files work now. --- http/404.html | 1 - http/button.css | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ httpserver.lua | 7 +++++- 3 files changed, 67 insertions(+), 2 deletions(-) delete mode 100644 http/404.html create mode 100644 http/button.css diff --git a/http/404.html b/http/404.html deleted file mode 100644 index dd7b159..0000000 --- a/http/404.html +++ /dev/null @@ -1 +0,0 @@ -404 - Not Found

404 - Not Found

diff --git a/http/button.css b/http/button.css new file mode 100644 index 0000000..91921c5 --- /dev/null +++ b/http/button.css @@ -0,0 +1,61 @@ +body { + text-align: center; +} + +.button { + display: inline-block; + margin: 10px; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + -webkit-box-shadow: 0 8px 0 #c5376d, 0 15px 20px rgba(0, 0, 0, .35); + -moz-box-shadow: 0 8px 0 #c5376d, 0 15px 20px rgba(0, 0, 0, .35); + box-shadow: 0 8px 0 #c5376d, 0 15px 20px rgba(0, 0, 0, .35); + -webkit-transition: -webkit-box-shadow .1s ease-in-out; + -moz-transition: -moz-box-shadow .1s ease-in-out; + -o-transition: -o-box-shadow .1s ease-in-out; + transition: box-shadow .1s ease-in-out; + font-size: 50px; + color: #fff; +} + +.button span { + display: inline-block; + padding: 20px 30px; + background-color: #ec528d; + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(hsla(338, 90%, 80%, .8)), to(hsla(338, 90%, 70%, .2))); + background-image: -webkit-linear-gradient(hsla(338, 90%, 80%, .8), hsla(338, 90%, 70%, .2)); + background-image: -moz-linear-gradient(hsla(338, 90%, 80%, .8), hsla(338, 90%, 70%, .2)); + background-image: -o-linear-gradient(hsla(338, 90%, 80%, .8), hsla(338, 90%, 70%, .2)); + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + -webkit-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, .15); + -moz-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, .15); + box-shadow: inset 0 -1px 1px rgba(255, 255, 255, .15); + font-family: 'Pacifico', Arial, sans-serif; + line-height: 1; + text-shadow: 0 -1px 1px rgba(175, 49, 95, .7); + -webkit-transition: background-color .2s ease-in-out, -webkit-transform .1s ease-in-out; + -moz-transition: background-color .2s ease-in-out, -moz-transform .1s ease-in-out; + -o-transition: background-color .2s ease-in-out, -o-transform .1s ease-in-out; + transition: background-color .2s ease-in-out, transform .1s ease-in-out; +} + +.button:hover span { + background-color: #ec6a9c; + text-shadow: 0 -1px 1px rgba(175, 49, 95, .9), 0 0 5px rgba(255, 255, 255, .8); +} + +.button:active, .button:focus { + -webkit-box-shadow: 0 8px 0 #c5376d, 0 12px 10px rgba(0, 0, 0, .3); + -moz-box-shadow: 0 8px 0 #c5376d, 0 12px 10px rgba(0, 0, 0, .3); + box-shadow: 0 8px 0 #c5376d, 0 12px 10px rgba(0, 0, 0, .3); +} + +.button:active span { + -webkit-transform: translate(0, 4px); + -moz-transform: translate(0, 4px); + -o-transform: translate(0, 4px); + transform: translate(0, 4px); +} diff --git a/httpserver.lua b/httpserver.lua index a526904..975ea07 100644 --- a/httpserver.lua +++ b/httpserver.lua @@ -59,7 +59,12 @@ local function onGet(connection, uri) else -- Use HTTP/1.0 to ensure client closes connection. connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\Cache-Control: private, no-store\r\n\r\n") - connection:send(file.read()) + -- Send file in little 128-byte chunks + while true do + local chunk = file.read(128) + if chunk == nil then break end + connection:send(chunk) + end connection:close() file.close() end