Mercurial Hosting > luan
comparison src/luan/modules/http/Http.luan @ 1260:4b5b84853f6f
replace Table.as_table with Luan.to_table
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Sep 2018 22:32:34 -0600 |
parents | e8020216dee7 |
children | 198d6af7330a |
comparison
equal
deleted
inserted
replaced
1259:e8020216dee7 | 1260:4b5b84853f6f |
---|---|
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 local old_java_to_luan = Luan.java_to_luan or error() | 28 local old_to_table = Luan.to_table or error() |
29 | 29 |
30 local function java_to_luan(obj) | 30 local function to_table(obj) |
31 obj = old_java_to_luan(obj) | |
32 if type(obj)=="java" and obj.instanceof(Request.MultipartFile) then | 31 if type(obj)=="java" and obj.instanceof(Request.MultipartFile) then |
33 return { | 32 return { |
34 filename = obj.filename | 33 filename = obj.filename |
35 content_type = obj.contentType | 34 content_type = obj.contentType |
36 content = obj.content | 35 content = obj.content |
37 } | 36 } |
38 end | 37 end |
39 return obj | 38 return old_to_table(obj) |
40 end | 39 end |
41 | 40 |
42 function Http.new_request(java) | 41 function Http.new_request(java) |
43 local this = {} | 42 local this = {} |
44 Http.request = this | 43 Http.request = this |
55 this.raw_path = java.rawPath or error() | 54 this.raw_path = java.rawPath or error() |
56 this.path = java.path or error() | 55 this.path = java.path or error() |
57 this.protocol = java.protocol or error() | 56 this.protocol = java.protocol or error() |
58 this.scheme = java.scheme or error() | 57 this.scheme = java.scheme or error() |
59 this.headers = to_luan(java.headers) | 58 this.headers = to_luan(java.headers) |
60 this.parameters = to_luan(java.parameters,java_to_luan) | 59 this.parameters = to_luan(java.parameters,to_table) |
61 this.cookies = to_luan(java.cookies) | 60 this.cookies = to_luan(java.cookies) |
62 end | 61 end |
63 | 62 |
64 function this.url() | 63 function this.url() |
65 return this.scheme.."://"..this.headers["host"]..this.raw_path | 64 return this.scheme.."://"..this.headers["host"]..this.raw_path |