Mercurial Hosting > luan
diff http/src/luan/modules/http/Http.luan @ 572:f1601a4ce1aa
fix stack when calling meta-methods
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 12 Jul 2015 21:34:23 -0600 |
parents | aa17ad66a370 |
children | 1e69d9c21461 |
line wrap: on
line diff
--- a/http/src/luan/modules/http/Http.luan Wed Jul 08 23:10:52 2015 -0600 +++ b/http/src/luan/modules/http/Http.luan Sun Jul 12 21:34:23 2015 -0600 @@ -1,12 +1,12 @@ java() local Luan = require "luan:Luan" -local ipairs = Luan.ipairs -local pairs = Luan.pairs local error = Luan.error -local set_metatable = Luan.set_metatable +local ipairs = Luan.ipairs or error() +local pairs = Luan.pairs or error() +local set_metatable = Luan.set_metatable or error() local Io = require "luan:Io" local Html = require "luan:Html" -local url_encode = Html.url_encode +local url_encode = Html.url_encode or error() local HttpServicer = require "java:luan.modules.http.HttpServicer" local IoLuan = require "java:luan.modules.IoLuan" @@ -31,6 +31,13 @@ end end +local function sent_error() + error "headers are not accessible after you start writing content" +end + +M.sent_error_metatable = { __index=sent_error, __new_index=sent_error } + + local function new_common(this) this = this or {} @@ -104,6 +111,7 @@ function this.set() HttpServicer.setResponse(this,this.java) + set_metatable(this.headers,M.sent_error_metatable) end function this.text_writer()