comparison 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
comparison
equal deleted inserted replaced
1160:4beabb087be6 1161:6baccd0c85a7
75 function this.send_redirect(location) 75 function this.send_redirect(location)
76 this.status = STATUS.FOUND 76 this.status = STATUS.FOUND
77 this.headers["location"] = location 77 this.headers["location"] = location
78 end 78 end
79 79
80 function this.send_error(status,msg)
81 this.status = status
82 if msg ~= nil then
83 this.headers["content-type"] = "text/plain"
84 local writer = this.text_writer()
85 writer.write(msg)
86 end
87 end
88
80 function this.set_cookie(name,value,attributes) 89 function this.set_cookie(name,value,attributes)
81 HttpServicer.setCookie(this.java,name,value,attributes) 90 HttpServicer.setCookie(this.java,name,value,attributes)
82 end 91 end
83 92
84 function this.set_persistent_cookie(name,value,attributes) 93 function this.set_persistent_cookie(name,value,attributes)
92 attributes["Max-Age"] = "0" 101 attributes["Max-Age"] = "0"
93 this.set_cookie(name,"delete",attributes) 102 this.set_cookie(name,"delete",attributes)
94 end 103 end
95 104
96 function this.text_writer() 105 function this.text_writer()
97 this.writer and error "writer already set"
98 this.writer = ResponseOutputStream.new(this.java) 106 this.writer = ResponseOutputStream.new(this.java)
99 this.writer = OutputStreamWriter.new(this.writer) 107 this.writer = OutputStreamWriter.new(this.writer)
100 return IoLuan.textWriter(this.writer) 108 return IoLuan.textWriter(this.writer)
101 end 109 end
102 110
103 function this.binary_writer() 111 function this.binary_writer()
104 this.writer and error "writer already set"
105 this.writer = ResponseOutputStream.new(this.java) 112 this.writer = ResponseOutputStream.new(this.java)
106 return IoLuan.binaryWriter(this.writer) 113 return IoLuan.binaryWriter(this.writer)
107 end 114 end
108 115
109 return this 116 return this