Decent makefiles!
This commit is contained in:
parent
d1a72435d5
commit
bce60be30f
58 changed files with 852 additions and 546 deletions
10
src/http.lua
10
src/http.lua
|
@ -13,6 +13,7 @@ local url = require("socket.url")
|
|||
local ltn12 = require("ltn12")
|
||||
local mime = require("mime")
|
||||
local string = require("string")
|
||||
local headers = require("socket.headers")
|
||||
local base = _G
|
||||
local table = require("table")
|
||||
module("socket.http")
|
||||
|
@ -123,10 +124,11 @@ function metat.__index:sendrequestline(method, uri)
|
|||
return self.try(self.c:send(reqline))
|
||||
end
|
||||
|
||||
function metat.__index:sendheaders(headers)
|
||||
function metat.__index:sendheaders(tosend)
|
||||
local canonic = headers.canonic
|
||||
local h = "\r\n"
|
||||
for i, v in base.pairs(headers) do
|
||||
h = i .. ": " .. v .. "\r\n" .. h
|
||||
for f, v in base.pairs(tosend) do
|
||||
h = (canonic[f] or f) .. ": " .. v .. "\r\n" .. h
|
||||
end
|
||||
self.try(self.c:send(h))
|
||||
return 1
|
||||
|
@ -254,7 +256,7 @@ local function shouldredirect(reqt, code, headers)
|
|||
return headers.location and
|
||||
string.gsub(headers.location, "%s", "") ~= "" and
|
||||
(reqt.redirect ~= false) and
|
||||
(code == 301 or code == 302) and
|
||||
(code == 301 or code == 302 or code == 303 or code == 307) and
|
||||
(not reqt.method or reqt.method == "GET" or reqt.method == "HEAD")
|
||||
and (not reqt.nredirects or reqt.nredirects < 5)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue