PtokaX forum

Development Section => Your Developing Problems => Topic started by: TTB on 22 July, 2015, 17:21:16

Title: LuaSocket question
Post by: TTB on 22 July, 2015, 17:21:16
I'm have a question about luasocket.
Little code:

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

-- Example 1
local s,fd = "",http.request(myFeed)
-- Example 2
local headers = {["user-agent"] = "Something"}
local r, c, h = http.request {
method = "HEAD",
url = myFeed,
headers = headers,
}


On example 1, I get the plain HTML code, which in this case doesn't work anymore on the site I use it because it needs a user agent. So I've added a user agent and my new situation is example 2. Unfortunatly I get on string c the "200" status and not the HTML code I want te receive.

How do I get the behaviour like example 1 and using a spoofed user agent header?
Using PtokaX 0.4.1.1 and LuaSocket 1.22 (regarding the html.lua code)
Title: Re: LuaSocket question
Post by: TTB on 22 July, 2015, 21:21:46
Hmm regarding this post it works as designed: http://stackoverflow.com/questions/17372330/lua-socket-post (http://stackoverflow.com/questions/17372330/lua-socket-post)
The body of the page can't be resolved by using headers it seems. Or....  am I wrong.   :ermm:
Title: Re: LuaSocket question
Post by: TTB on 23 July, 2015, 22:08:39
OK fixed it... I've eddited the html.lua and replaced the default user agent into something I like, such as IE11 or Chrome or Firefox...