19.02.2019, 09:16
So then you just need to pass cookie header to the next request:
Code:
require('socket.http')
socket.http.TIMEOUT = 5
url1 = ...
url2 = ...
res, err, hdrs = socket.http.request(url1)
if res then
tbl = {}
res, err = socket.http.request({
url = url2,
headers = {
cookie = hdrs['set-cookie']
},
sink = ltn12.sink.table(tbl),
})
if res then
resp = table.concat(tbl)
log(resp)
else
alert('request 2 failed: ' .. tostring(err))
end
else
alert('request 1 failed: ' .. tostring(err))
end