Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
1152:21d157b153fe | 1153:1f4da56abd4f |
---|---|
49 -- this.path | 49 -- this.path |
50 -- this.protocol | 50 -- this.protocol |
51 this.scheme = "http" -- default | 51 this.scheme = "http" -- default |
52 this.port = 80 -- default | 52 this.port = 80 -- default |
53 this.parameters = {} | 53 this.parameters = {} |
54 this.cookie = {} | 54 this.cookies = {} |
55 | 55 |
56 function this.query_string() | 56 function this.query_string() |
57 local string_uri = Io.uri "string:" | 57 local string_uri = Io.uri "string:" |
58 local out = string_uri.text_writer() | 58 local out = string_uri.text_writer() |
59 local and_char = "" | 59 local and_char = "" |
94 this.status = STATUS.OK | 94 this.status = STATUS.OK |
95 if this.java ~= nil then | 95 if this.java ~= nil then |
96 this.send_redirect = this.java.sendRedirect | 96 this.send_redirect = this.java.sendRedirect |
97 this.send_error = this.java.sendError | 97 this.send_error = this.java.sendError |
98 | 98 |
99 function this.set_cookie(name,value,is_persistent,domain) | 99 function this.set_cookie(name,value,attributes) |
100 HttpServicer.setCookie(Http.request.java,this.java,name,value,is_persistent,domain) | 100 HttpServicer.setCookie(Http.request.java,this.java,name,value,attributes) |
101 end | 101 end |
102 | 102 |
103 function this.set_persistent_cookie(name,value,attributes) { | |
104 attributes = attributes or {} | |
105 attributes["Max-Age"] = "10000000" | |
106 this.set_cookie(name,value,attributes) | |
107 } | |
108 | |
103 function this.remove_cookie(name,domain) | 109 function this.remove_cookie(name,domain) |
104 HttpServicer.removeCookie(Http.request.java,this.java,name,domain) | 110 attributes = attributes or {} |
111 attributes["Max-Age"] = "0" | |
112 this.set_cookie(name,value,attributes) | |
105 end | 113 end |
106 | 114 |
107 function this.set() | 115 function this.set() |
108 HttpServicer.setResponse(this,this.java) | 116 HttpServicer.setResponse(this,this.java) |
109 Http.sent_headers(this.headers) | 117 Http.sent_headers(this.headers) |