Mercurial Hosting > luan
comparison src/luan/modules/http/Http.luan @ 1226:b6aa2cd51b02
Http cleanup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 01 Apr 2018 19:42:47 -0600 |
parents | d5d5d29d7592 |
children | 275d1b52dbce |
comparison
equal
deleted
inserted
replaced
1225:7d4b5afb636f | 1226:b6aa2cd51b02 |
---|---|
23 local HashMap = require "java:java.util.HashMap" | 23 local HashMap = require "java:java.util.HashMap" |
24 | 24 |
25 | 25 |
26 local Http = {} | 26 local Http = {} |
27 | 27 |
28 Http.version = "luan" | |
29 | |
30 function Http.new_request(java) | 28 function Http.new_request(java) |
31 local this = {} | 29 local this = {} |
32 Http.request = this | 30 Http.request = this |
33 if java == nil then | 31 if java == nil then |
34 this.method = "GET" | 32 this.method = "GET" |
45 this.headers = JavaLuan.toLuan(java.headers) | 43 this.headers = JavaLuan.toLuan(java.headers) |
46 this.parameters = JavaLuan.toLuan(java.parameters) | 44 this.parameters = JavaLuan.toLuan(java.parameters) |
47 this.cookies = JavaLuan.toLuan(java.cookies) | 45 this.cookies = JavaLuan.toLuan(java.cookies) |
48 end | 46 end |
49 this.scheme = "http" | 47 this.scheme = "http" |
50 | |
51 function this.full_path() -- compatible with jetty | |
52 return this.raw_path or this.path | |
53 end | |
54 | 48 |
55 function this.url() | 49 function this.url() |
56 return this.scheme.."://"..this.headers["host"]..this.raw_path | 50 return this.scheme.."://"..this.headers["host"]..this.raw_path |
57 end | 51 end |
58 | 52 |
148 end | 142 end |
149 response.writer and response.writer.close() | 143 response.writer and response.writer.close() |
150 return java | 144 return java |
151 end | 145 end |
152 | 146 |
153 | |
154 function Http.uncache_site() | |
155 for k in pairs(Table.copy(Package.loaded)) do | |
156 if matches(k,"^site:") then | |
157 Package.loaded[k] = nil | |
158 end | |
159 end | |
160 end | |
161 | |
162 return Http | 147 return Http |