mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-04-30 20:26:44 +02:00
Compare commits
4 Commits
bb0283b3e5
...
7c8858450c
Author | SHA1 | Date | |
---|---|---|---|
|
7c8858450c | ||
|
fa69770e52 | ||
|
13f2b3c663 | ||
|
39a8b34e4a |
13
src/http.lua
13
src/http.lua
@ -62,7 +62,7 @@ local function receiveheaders(sock, headers)
|
|||||||
-- unfold any folded values
|
-- unfold any folded values
|
||||||
while string.find(line, "^%s") do
|
while string.find(line, "^%s") do
|
||||||
value = value .. line
|
value = value .. line
|
||||||
line = sock:receive()
|
line, err = sock:receive()
|
||||||
if err then return nil, err end
|
if err then return nil, err end
|
||||||
end
|
end
|
||||||
-- save pair in table
|
-- save pair in table
|
||||||
@ -219,9 +219,11 @@ local function adjustproxy(reqt)
|
|||||||
local proxy = reqt.proxy or _M.PROXY
|
local proxy = reqt.proxy or _M.PROXY
|
||||||
if proxy then
|
if proxy then
|
||||||
proxy = url.parse(proxy)
|
proxy = url.parse(proxy)
|
||||||
return proxy.host, proxy.port or 3128
|
proxy.port = proxy.port or 3128
|
||||||
|
proxy.create = SCHEMES[proxy.scheme].create(reqt)
|
||||||
|
return proxy.host, proxy.port, proxy.create
|
||||||
else
|
else
|
||||||
return reqt.host, reqt.port
|
return reqt.host, reqt.port, reqt.create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -291,7 +293,10 @@ local function adjustrequest(reqt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ajust host and port if there is a proxy
|
-- ajust host and port if there is a proxy
|
||||||
nreqt.host, nreqt.port = adjustproxy(nreqt)
|
local proxy_create
|
||||||
|
nreqt.host, nreqt.port, proxy_create = adjustproxy(nreqt)
|
||||||
|
if not reqt.create then nreqt.create = proxy_create end
|
||||||
|
|
||||||
return nreqt
|
return nreqt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -127,7 +127,19 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
|
|||||||
if (connect(*ps, addr, len) == 0) return IO_DONE;
|
if (connect(*ps, addr, len) == 0) return IO_DONE;
|
||||||
/* make sure the system is trying to connect */
|
/* make sure the system is trying to connect */
|
||||||
err = WSAGetLastError();
|
err = WSAGetLastError();
|
||||||
|
|
||||||
|
if (err == WSAEISCONN) return IO_DONE; // already connected?
|
||||||
|
|
||||||
|
// hotfix for nonblocking, slow TCP connections not returning instantly
|
||||||
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms737625(v=vs.85).aspx
|
||||||
|
// "Note In order to preserve backward compatibility, this error is reported as WSAEINVAL to Windows Sockets 1.1 applications that link to either Winsock.dll or Wsock32.dll."
|
||||||
|
// The only other valid reason to get WSAINVAL is that: The parameter s is a listening socket. So we hope that doesn't happen here.
|
||||||
|
if (err == WSAEINVAL) {
|
||||||
|
return WSAEALREADY;
|
||||||
|
}
|
||||||
|
|
||||||
if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err;
|
if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err;
|
||||||
|
|
||||||
/* zero timeout case optimization */
|
/* zero timeout case optimization */
|
||||||
if (timeout_iszero(tm)) return IO_TIMEOUT;
|
if (timeout_iszero(tm)) return IO_TIMEOUT;
|
||||||
/* we wait until something happens */
|
/* we wait until something happens */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user