lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

I write a http request program using luasocket.
To connect server, and send header and body is success.
But program always receive number:302.

I think My program don't support forward redirect system.

What should I write a program like?

my program is following:

-- my program 

local http = require("socket.http")
local ltn12 = require("ltn12")

...
	local myFile = io.open( path, "w+b" ) 

	
	request_body = "(write some POST parameter here) "

	print("start")
	
	-- Request remote file and save data to local file
	local r,c,h = http.request{ 
	   method = "POST", 
	   url = (some url),
	   headers = {
	      ["Content-Type"] =  "application/x-www-form-urlencoded",
	      ["Content-Length"] = string.len(request_body),
	   },
	   source = ltn12.source.string(request_body), 
	   sink = ltn12.sink.file(myFile),
	   redirect = true
	}

...

--

Keisuke Kimura <k0227n0319@gmail.com>