From be57b387d2394cc670b37e04edab41e293d47560 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Wed, 12 Apr 2006 08:04:09 +0000 Subject: [PATCH] Stupid bug was reusing the nreqt.headers.host during redirect. --- TODO | 10 ++++++++++ src/http.lua | 19 +++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index ac4291c..d79aea5 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,13 @@ +New mime support + + + + + + + + + ftp send should return server replies? make sure there are no object files in the distribution tarball http handling of 100-continue, see DB patch diff --git a/src/http.lua b/src/http.lua index bfa0345..6465c29 100644 --- a/src/http.lua +++ b/src/http.lua @@ -15,7 +15,6 @@ local mime = require("mime") local string = require("string") local base = _G local table = require("table") -local print = print module("socket.http") ----------------------------------------------------------------------------- @@ -278,16 +277,16 @@ end function trequest(reqt) -- we loop until we get what we want, or -- until we are sure there is no way to get it - reqt = adjustrequest(reqt) - local h = open(reqt.host, reqt.port, reqt.create) + local nreqt = adjustrequest(reqt) + local h = open(nreqt.host, nreqt.port, nreqt.create) -- send request line and headers - h:sendrequestline(reqt.method, reqt.uri) - h:sendheaders(reqt.headers) + h:sendrequestline(nreqt.method, nreqt.uri) + h:sendheaders(nreqt.headers) local code = 100 local headers, status -- if there is a body, check for server status - if reqt.source then - h:sendbody(reqt.headers, reqt.source, reqt.step) + if nreqt.source then + h:sendbody(nreqt.headers, nreqt.source, nreqt.step) end -- ignore any 100-continue messages while code == 100 do @@ -296,13 +295,13 @@ function trequest(reqt) end -- at this point we should have a honest reply from the server -- we can't redirect if we already used the source, so we report the error - if shouldredirect(reqt, code, headers) and not reqt.source then + if shouldredirect(nreqt, code, headers) and not nreqt.source then h:close() return tredirect(reqt, headers.location) end -- here we are finally done - if shouldreceivebody(reqt, code) then - h:receivebody(headers, reqt.sink, reqt.step) + if shouldreceivebody(nreqt, code) then + h:receivebody(headers, nreqt.sink, nreqt.step) end h:close() return 1, code, headers, status