Mercurial Hosting > luan
comparison src/luan/modules/http/HttpServicer.java @ 796:6b8ea0a9b7c9
remove LuanMeta
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 05 Sep 2016 19:52:49 -0600 |
parents | 60661a8e738c |
children | 9eccfede1094 |
comparison
equal
deleted
inserted
replaced
795:dd36eae6aa04 | 796:6b8ea0a9b7c9 |
---|---|
26 import luan.Luan; | 26 import luan.Luan; |
27 import luan.LuanState; | 27 import luan.LuanState; |
28 import luan.LuanFunction; | 28 import luan.LuanFunction; |
29 import luan.LuanException; | 29 import luan.LuanException; |
30 import luan.LuanTable; | 30 import luan.LuanTable; |
31 import luan.LuanPropertyMeta; | 31 //import luan.LuanPropertyMeta; |
32 import luan.LuanCloner; | 32 import luan.LuanCloner; |
33 import luan.modules.PackageLuan; | 33 import luan.modules.PackageLuan; |
34 import luan.modules.IoLuan; | 34 import luan.modules.IoLuan; |
35 import luan.modules.TableLuan; | 35 import luan.modules.TableLuan; |
36 import luan.modules.Utils; | 36 import luan.modules.Utils; |
124 Object value; | 124 Object value; |
125 String filename = part.getContentDispositionFilename(); | 125 String filename = part.getContentDispositionFilename(); |
126 if( filename == null ) { | 126 if( filename == null ) { |
127 value = new String(part.getBytes()); | 127 value = new String(part.getBytes()); |
128 } else { | 128 } else { |
129 /* | |
129 LuanTable partTbl = LuanPropertyMeta.INSTANCE.newTable(); | 130 LuanTable partTbl = LuanPropertyMeta.INSTANCE.newTable(); |
130 partTbl.rawPut("filename",filename); | 131 partTbl.rawPut("filename",filename); |
131 partTbl.rawPut("content_type",part.getContentType()); | 132 partTbl.rawPut("content_type",part.getContentType()); |
132 LuanPropertyMeta.INSTANCE.getters(partTbl).rawPut( "content", new LuanFunction() { | 133 LuanPropertyMeta.INSTANCE.getters(partTbl).rawPut( "content", new LuanFunction() { |
133 @Override public Object call(LuanState luan,Object[] args) throws LuanException { | 134 @Override public Object call(LuanState luan,Object[] args) throws LuanException { |
139 } catch(IOException e) { | 140 } catch(IOException e) { |
140 throw new RuntimeException(e); | 141 throw new RuntimeException(e); |
141 } | 142 } |
142 } | 143 } |
143 } ); | 144 } ); |
145 */ | |
146 LuanTable partTbl = new LuanTable(); | |
147 partTbl.rawPut("filename",filename); | |
148 partTbl.rawPut("content_type",part.getContentType()); | |
149 LuanTable mt = new LuanTable(); | |
150 partTbl.setMetatable(mt); | |
151 mt.rawPut( "__index", new LuanFunction() { | |
152 @Override public Object call(LuanState luan,Object[] args) throws LuanException { | |
153 Object key = args[1]; | |
154 if( "content".equals(key) ) { | |
155 try { | |
156 InputStream in = part.getInputStream(); | |
157 byte[] content = Utils.readAll(in); | |
158 in.close(); | |
159 return content; | |
160 } catch(IOException e) { | |
161 throw new RuntimeException(e); | |
162 } | |
163 } | |
164 return null; | |
165 } | |
166 } ); | |
144 value = partTbl; | 167 value = partTbl; |
145 } | 168 } |
146 LuanTable list = (LuanTable)parametersTbl.rawGet(name); | 169 LuanTable list = (LuanTable)parametersTbl.rawGet(name); |
147 if( list == null ) { | 170 if( list == null ) { |
148 list = new LuanTable(); | 171 list = new LuanTable(); |