From bce60be30fe8e9c1b0eb33128c23c93d7bca5303 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Wed, 27 May 2009 09:31:38 +0000 Subject: Decent makefiles! --- src/http.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/http.lua') diff --git a/src/http.lua b/src/http.lua index 3a386a6..4c27149 100644 --- a/src/http.lua +++ b/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 -- cgit v1.2.3-55-g6feb