Mercurial Hosting > luan
comparison src/luan/modules/http/Http.luan @ 1261:198d6af7330a
rename Luan.to_table to Table.java_to_table_shallow and Luan.to_luan to Table.java_to_table_deep
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 24 Sep 2018 13:09:16 -0600 |
parents | 4b5b84853f6f |
children | 382c444a6c77 |
comparison
equal
deleted
inserted
replaced
1260:4b5b84853f6f | 1261:198d6af7330a |
---|---|
2 local Luan = require "luan:Luan.luan" | 2 local Luan = require "luan:Luan.luan" |
3 local error = Luan.error | 3 local error = Luan.error |
4 local ipairs = Luan.ipairs or error() | 4 local ipairs = Luan.ipairs or error() |
5 local pairs = Luan.pairs or error() | 5 local pairs = Luan.pairs or error() |
6 local type = Luan.type or error() | 6 local type = Luan.type or error() |
7 local to_luan = Luan.to_luan or error() | |
8 local Io = require "luan:Io.luan" | 7 local Io = require "luan:Io.luan" |
9 local Html = require "luan:Html.luan" | 8 local Html = require "luan:Html.luan" |
10 local Table = require "luan:Table.luan" | 9 local Table = require "luan:Table.luan" |
11 local clear = Table.clear or error() | 10 local clear = Table.clear or error() |
11 local java_to_table_deep = Table.java_to_table_deep or error() | |
12 local Package = require "luan:Package.luan" | 12 local Package = require "luan:Package.luan" |
13 local String = require "luan:String.luan" | 13 local String = require "luan:String.luan" |
14 local lower = String.lower or error() | 14 local lower = String.lower or error() |
15 local matches = String.matches or error() | 15 local matches = String.matches or error() |
16 local IoLuan = require "java:luan.modules.IoLuan" | 16 local IoLuan = require "java:luan.modules.IoLuan" |
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_to_table = Luan.to_table or error() | 28 local old_java_to_table_shallow = Table.java_to_table_shallow or error() |
29 | 29 |
30 local function to_table(obj) | 30 local function java_to_table_shallow(obj) |
31 if type(obj)=="java" and obj.instanceof(Request.MultipartFile) then | 31 if type(obj)=="java" and obj.instanceof(Request.MultipartFile) then |
32 return { | 32 return { |
33 filename = obj.filename | 33 filename = obj.filename |
34 content_type = obj.contentType | 34 content_type = obj.contentType |
35 content = obj.content | 35 content = obj.content |
36 } | 36 } |
37 end | 37 end |
38 return old_to_table(obj) | 38 return old_java_to_table_shallow(obj) |
39 end | 39 end |
40 | 40 |
41 function Http.new_request(java) | 41 function Http.new_request(java) |
42 local this = {} | 42 local this = {} |
43 Http.request = this | 43 Http.request = this |
53 this.method = java.method or error() | 53 this.method = java.method or error() |
54 this.raw_path = java.rawPath or error() | 54 this.raw_path = java.rawPath or error() |
55 this.path = java.path or error() | 55 this.path = java.path or error() |
56 this.protocol = java.protocol or error() | 56 this.protocol = java.protocol or error() |
57 this.scheme = java.scheme or error() | 57 this.scheme = java.scheme or error() |
58 this.headers = to_luan(java.headers) | 58 this.headers = java_to_table_deep(java.headers) |
59 this.parameters = to_luan(java.parameters,to_table) | 59 this.parameters = java_to_table_deep(java.parameters,java_to_table_shallow) |
60 this.cookies = to_luan(java.cookies) | 60 this.cookies = java_to_table_deep(java.cookies) |
61 end | 61 end |
62 | 62 |
63 function this.url() | 63 function this.url() |
64 return this.scheme.."://"..this.headers["host"]..this.raw_path | 64 return this.scheme.."://"..this.headers["host"]..this.raw_path |
65 end | 65 end |