Mercurial Hosting > luan
comparison http/src/luan/modules/http/HttpServicer.java @ 500:ab9c2afefb47
add response.binary_writer
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 18 May 2015 20:59:30 -0600 |
parents | fa4af530697f |
children | dbdf4b8193a8 |
comparison
equal
deleted
inserted
replaced
499:fa4af530697f | 500:ab9c2afefb47 |
---|---|
89 String key = enKeys.nextElement(); | 89 String key = enKeys.nextElement(); |
90 LuanTable values = new LuanTable(); | 90 LuanTable values = new LuanTable(); |
91 for( Enumeration<String> en = request.getHeaders(key); en.hasMoreElements(); ) { | 91 for( Enumeration<String> en = request.getHeaders(key); en.hasMoreElements(); ) { |
92 values.rawPut(values.rawLength()+1,en.nextElement()); | 92 values.rawPut(values.rawLength()+1,en.nextElement()); |
93 } | 93 } |
94 key = key.toLowerCase().replace('-','_'); | 94 key = toLuanHeaderName(key); |
95 headersTbl.rawPut(key,values); | 95 headersTbl.rawPut(key,values); |
96 } | 96 } |
97 | 97 |
98 LuanTable parametersTbl = (LuanTable)requestTbl.rawGet("parameters"); | 98 LuanTable parametersTbl = (LuanTable)requestTbl.rawGet("parameters"); |
99 String contentType = request.getContentType(); | 99 String contentType = request.getContentType(); |
178 int status = Luan.asInteger(responseTbl.rawGet("status")); | 178 int status = Luan.asInteger(responseTbl.rawGet("status")); |
179 response.setStatus(status); | 179 response.setStatus(status); |
180 LuanTable responseHeaders = (LuanTable)responseTbl.rawGet("headers"); | 180 LuanTable responseHeaders = (LuanTable)responseTbl.rawGet("headers"); |
181 for( Map.Entry<Object,Object> entry : responseHeaders.rawIterable() ) { | 181 for( Map.Entry<Object,Object> entry : responseHeaders.rawIterable() ) { |
182 String name = (String)entry.getKey(); | 182 String name = (String)entry.getKey(); |
183 name = toHeaderName(name); | 183 name = toHttpHeaderName(name); |
184 LuanTable values = (LuanTable)entry.getValue(); | 184 LuanTable values = (LuanTable)entry.getValue(); |
185 for( Object value : values.asList() ) { | 185 for( Object value : values.asList() ) { |
186 if( value instanceof String ) { | 186 if( value instanceof String ) { |
187 response.setHeader(name,(String)value); | 187 response.setHeader(name,(String)value); |
188 continue; | 188 continue; |
202 | 202 |
203 | 203 |
204 | 204 |
205 // static utils | 205 // static utils |
206 | 206 |
207 public static String toHeaderName(String luanName) { | 207 public static String toLuanHeaderName(String httpName) { |
208 return httpName.toLowerCase().replace('-','_'); | |
209 } | |
210 | |
211 public static String toHttpHeaderName(String luanName) { | |
208 StringBuilder buf = new StringBuilder(); | 212 StringBuilder buf = new StringBuilder(); |
209 boolean capitalize = true; | 213 boolean capitalize = true; |
210 char[] a = luanName.toCharArray(); | 214 char[] a = luanName.toCharArray(); |
211 for( int i=0; i<a.length; i++ ) { | 215 for( int i=0; i<a.length; i++ ) { |
212 char c = a[i]; | 216 char c = a[i]; |