Merge pull request #10 from camchenry/master

Fix XML parsing errors #9
This commit is contained in:
rxi
2017-04-29 15:45:43 +01:00
committed by GitHub

View File

@@ -49,6 +49,7 @@ end
<html> <html>
<head> <head>
<meta http-equiv="x-ua-compatible" content="IE=Edge"/> <meta http-equiv="x-ua-compatible" content="IE=Edge"/>
<meta charset="utf-8">
<title>lovebird</title> <title>lovebird</title>
<style> <style>
body { body {
@@ -613,7 +614,12 @@ function lovebird.onrequest(req, client)
local str local str
xpcall(function() xpcall(function()
local data = lovebird.pages[page](lovebird, req) local data = lovebird.pages[page](lovebird, req)
local contenttype = "text/html"
if string.match(page, "%.json$") then
contenttype = "application/json"
end
str = "HTTP/1.1 200 OK\r\n" .. str = "HTTP/1.1 200 OK\r\n" ..
"Content-Type: " .. contenttype .. "\r\n" ..
"Content-Length: " .. #data .. "\r\n" .. "Content-Length: " .. #data .. "\r\n" ..
"\r\n" .. data "\r\n" .. data
end, lovebird.onerror) end, lovebird.onerror)