Mercurial Hosting > luan
diff src/luan/modules/http/impl/Http.luan @ 1161:6baccd0c85a7
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 05 Feb 2018 22:59:52 -0700 |
parents | 4beabb087be6 |
children | e2d2354807f3 |
line wrap: on
line diff
--- a/src/luan/modules/http/impl/Http.luan Mon Feb 05 22:33:59 2018 -0700 +++ b/src/luan/modules/http/impl/Http.luan Mon Feb 05 22:59:52 2018 -0700 @@ -77,6 +77,15 @@ this.headers["location"] = location end + function this.send_error(status,msg) + this.status = status + if msg ~= nil then + this.headers["content-type"] = "text/plain" + local writer = this.text_writer() + writer.write(msg) + end + end + function this.set_cookie(name,value,attributes) HttpServicer.setCookie(this.java,name,value,attributes) end @@ -94,14 +103,12 @@ end function this.text_writer() - this.writer and error "writer already set" this.writer = ResponseOutputStream.new(this.java) this.writer = OutputStreamWriter.new(this.writer) return IoLuan.textWriter(this.writer) end function this.binary_writer() - this.writer and error "writer already set" this.writer = ResponseOutputStream.new(this.java) return IoLuan.binaryWriter(this.writer) end