Author Topic: LuaSocket question  (Read 1692 times)

0 Members and 1 Guest are viewing this topic.

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
LuaSocket question
« on: 22 July, 2015, 17:21:16 »
I'm have a question about luasocket.
Little code:
Code: [Select]
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)
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

PtokaX forum

LuaSocket question
« on: 22 July, 2015, 17:21:16 »

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
Re: LuaSocket question
« Reply #1 on: 22 July, 2015, 21:21:46 »
Hmm regarding this post it works as designed: 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:
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
Re: LuaSocket question
« Reply #2 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...
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

PtokaX forum

Re: LuaSocket question
« Reply #2 on: 23 July, 2015, 22:08:39 »