comparison src/luan/modules/http/Http.luan @ 1150:0842b9b570f8

change http headers interface
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 04 Feb 2018 18:03:37 -0700
parents d30d400fd43d
children 21d157b153fe
comparison
equal deleted inserted replaced
1149:1b7c20e20ca7 1150:0842b9b570f8
50 50
51 51
52 local function new_common(this) 52 local function new_common(this)
53 this = this or {} 53 this = this or {}
54 this.headers = {} 54 this.headers = {}
55 this.header = {__plural=this.headers}
56 set_metatable(this.header,singular_metatable)
57 return this 55 return this
58 end 56 end
59 57
60 58
61 function Http.new_request(this) 59 function Http.new_request(this)
84 local s = string_uri.read_text() 82 local s = string_uri.read_text()
85 return s ~= "" and s or nil 83 return s ~= "" and s or nil
86 end 84 end
87 85
88 function this.url() 86 function this.url()
89 local url = this.scheme.."://"..this.header.host..this.path 87 local url = this.scheme.."://"..this.headers["host"]..this.path
90 if this.method ~= "POST" then 88 if this.method ~= "POST" then
91 local query = this.query_string() 89 local query = this.query_string()
92 if query ~= nil then 90 if query ~= nil then
93 url = url.."?"..query 91 url = url.."?"..query
94 end 92 end