Mercurial Hosting > luan
diff src/luan/modules/http/Http.luan @ 1153:1f4da56abd4f
change http cookies interface
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 04 Feb 2018 20:01:23 -0700 |
parents | 21d157b153fe |
children | bbad9a21277c |
line wrap: on
line diff
--- a/src/luan/modules/http/Http.luan Sun Feb 04 19:25:12 2018 -0700 +++ b/src/luan/modules/http/Http.luan Sun Feb 04 20:01:23 2018 -0700 @@ -51,7 +51,7 @@ this.scheme = "http" -- default this.port = 80 -- default this.parameters = {} - this.cookie = {} + this.cookies = {} function this.query_string() local string_uri = Io.uri "string:" @@ -96,12 +96,20 @@ this.send_redirect = this.java.sendRedirect this.send_error = this.java.sendError - function this.set_cookie(name,value,is_persistent,domain) - HttpServicer.setCookie(Http.request.java,this.java,name,value,is_persistent,domain) + function this.set_cookie(name,value,attributes) + HttpServicer.setCookie(Http.request.java,this.java,name,value,attributes) end + function this.set_persistent_cookie(name,value,attributes) { + attributes = attributes or {} + attributes["Max-Age"] = "10000000" + this.set_cookie(name,value,attributes) + } + function this.remove_cookie(name,domain) - HttpServicer.removeCookie(Http.request.java,this.java,name,domain) + attributes = attributes or {} + attributes["Max-Age"] = "0" + this.set_cookie(name,value,attributes) end function this.set()