mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
Stupid bug was reusing the nreqt.headers.host during redirect.
This commit is contained in:
parent
11282d17c8
commit
be57b387d2
10
TODO
10
TODO
@ -1,3 +1,13 @@
|
|||||||
|
New mime support
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ftp send should return server replies?
|
ftp send should return server replies?
|
||||||
make sure there are no object files in the distribution tarball
|
make sure there are no object files in the distribution tarball
|
||||||
http handling of 100-continue, see DB patch
|
http handling of 100-continue, see DB patch
|
||||||
|
19
src/http.lua
19
src/http.lua
@ -15,7 +15,6 @@ local mime = require("mime")
|
|||||||
local string = require("string")
|
local string = require("string")
|
||||||
local base = _G
|
local base = _G
|
||||||
local table = require("table")
|
local table = require("table")
|
||||||
local print = print
|
|
||||||
module("socket.http")
|
module("socket.http")
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@ -278,16 +277,16 @@ end
|
|||||||
function trequest(reqt)
|
function trequest(reqt)
|
||||||
-- we loop until we get what we want, or
|
-- we loop until we get what we want, or
|
||||||
-- until we are sure there is no way to get it
|
-- until we are sure there is no way to get it
|
||||||
reqt = adjustrequest(reqt)
|
local nreqt = adjustrequest(reqt)
|
||||||
local h = open(reqt.host, reqt.port, reqt.create)
|
local h = open(nreqt.host, nreqt.port, nreqt.create)
|
||||||
-- send request line and headers
|
-- send request line and headers
|
||||||
h:sendrequestline(reqt.method, reqt.uri)
|
h:sendrequestline(nreqt.method, nreqt.uri)
|
||||||
h:sendheaders(reqt.headers)
|
h:sendheaders(nreqt.headers)
|
||||||
local code = 100
|
local code = 100
|
||||||
local headers, status
|
local headers, status
|
||||||
-- if there is a body, check for server status
|
-- if there is a body, check for server status
|
||||||
if reqt.source then
|
if nreqt.source then
|
||||||
h:sendbody(reqt.headers, reqt.source, reqt.step)
|
h:sendbody(nreqt.headers, nreqt.source, nreqt.step)
|
||||||
end
|
end
|
||||||
-- ignore any 100-continue messages
|
-- ignore any 100-continue messages
|
||||||
while code == 100 do
|
while code == 100 do
|
||||||
@ -296,13 +295,13 @@ function trequest(reqt)
|
|||||||
end
|
end
|
||||||
-- at this point we should have a honest reply from the server
|
-- 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
|
-- 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()
|
h:close()
|
||||||
return tredirect(reqt, headers.location)
|
return tredirect(reqt, headers.location)
|
||||||
end
|
end
|
||||||
-- here we are finally done
|
-- here we are finally done
|
||||||
if shouldreceivebody(reqt, code) then
|
if shouldreceivebody(nreqt, code) then
|
||||||
h:receivebody(headers, reqt.sink, reqt.step)
|
h:receivebody(headers, nreqt.sink, nreqt.step)
|
||||||
end
|
end
|
||||||
h:close()
|
h:close()
|
||||||
return 1, code, headers, status
|
return 1, code, headers, status
|
||||||
|
Loading…
Reference in New Issue
Block a user