comparison web/src/luan/modules/web/HttpServicer.java @ 416:91af5337b9ae

add LuanMeta.__tostring()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 30 Apr 2015 06:28:25 -0600
parents ce8e19567911
children 23a93c118042
comparison
equal deleted inserted replaced
415:ce8e19567911 416:91af5337b9ae
129 } 129 }
130 130
131 @Override protected Iterator keys(LuanTable tbl) { 131 @Override protected Iterator keys(LuanTable tbl) {
132 return new EnumerationIterator(request.getParameterNames()); 132 return new EnumerationIterator(request.getParameterNames());
133 } 133 }
134 /* 134
135 @Override protected String type() { 135 @Override protected String type(LuanTable tbl) {
136 return "request.parameters-table"; 136 return "request.parameters";
137 } 137 }
138 */ 138
139 }.newTable(); 139 }.newTable();
140 tbl.put( "parameters", parameters ); 140 tbl.put( "parameters", parameters );
141 add( tbl, "get_parameter_values", String.class ); 141 add( tbl, "get_parameter_values", String.class );
142 LuanTable headers = new NameMeta() { 142 LuanTable headers = new NameMeta() {
143 143
146 } 146 }
147 147
148 @Override protected Iterator keys(LuanTable tbl) { 148 @Override protected Iterator keys(LuanTable tbl) {
149 return new EnumerationIterator(request.getHeaderNames()); 149 return new EnumerationIterator(request.getHeaderNames());
150 } 150 }
151 /* 151
152 @Override protected String type() { 152 @Override protected String type(LuanTable tbl) {
153 return "request.headers-table"; 153 return "request.headers";
154 } 154 }
155 */ 155
156 }.newTable(); 156 }.newTable();
157 tbl.put( "headers", headers ); 157 tbl.put( "headers", headers );
158 getters.put( "method", new LuanJavaFunction( 158 getters.put( "method", new LuanJavaFunction(
159 HttpServletRequest.class.getMethod( "getMethod" ), request 159 HttpServletRequest.class.getMethod( "getMethod" ), request
160 ) ); 160 ) );
196 @Override public void remove() { 196 @Override public void remove() {
197 throw new UnsupportedOperationException(); 197 throw new UnsupportedOperationException();
198 } 198 }
199 }; 199 };
200 } 200 }
201 /* 201
202 @Override protected String type() { 202 @Override protected String type(LuanTable tbl) {
203 return "request.cookies-table"; 203 return "request.cookies";
204 } 204 }
205 */ 205
206 }.newTable(); 206 }.newTable();
207 tbl.put( "cookies", cookies ); 207 tbl.put( "cookies", cookies );
208 208
209 String contentType = request.getContentType(); 209 String contentType = request.getContentType();
210 if( contentType!=null && contentType.startsWith("multipart/form-data") ) { 210 if( contentType!=null && contentType.startsWith("multipart/form-data") ) {
303 response.setIntHeader(name,i); 303 response.setIntHeader(name,i);
304 return; 304 return;
305 } 305 }
306 throw new IllegalArgumentException("value must be string or integer for headers table"); 306 throw new IllegalArgumentException("value must be string or integer for headers table");
307 } 307 }
308 /* 308
309 @Override protected String type() { 309 @Override protected String type(LuanTable tbl) {
310 return "response.headers-table"; 310 return "response.headers";
311 } 311 }
312 */ 312
313 }.newTable(); 313 }.newTable();
314 tbl.put( "headers", headers ); 314 tbl.put( "headers", headers );
315 getters.put( "content_type", new LuanJavaFunction( 315 getters.put( "content_type", new LuanJavaFunction(
316 HttpServletResponse.class.getMethod( "getContentType" ), response 316 HttpServletResponse.class.getMethod( "getContentType" ), response
317 ) ); 317 ) );
356 if( !(key instanceof String) ) 356 if( !(key instanceof String) )
357 throw new IllegalArgumentException("key must be string for session attributes table"); 357 throw new IllegalArgumentException("key must be string for session attributes table");
358 String name = (String)key; 358 String name = (String)key;
359 request.getSession().setAttribute(name,val); 359 request.getSession().setAttribute(name,val);
360 } 360 }
361 /* 361
362 @Override protected String type() { 362 @Override protected String type(LuanTable tbl) {
363 return "session.attributes-table"; 363 return "session.attributes";
364 } 364 }
365 */ 365
366 }.newTable(); 366 }.newTable();
367 tbl.put( "attributes", attributes ); 367 tbl.put( "attributes", attributes );
368 return tbl; 368 return tbl;
369 } 369 }
370 370