Luasocket custom headers, 404 turns to 301

前端 未结 2 1070
清歌不尽
清歌不尽 2021-01-23 02:45

My previous question was about fetching page title in lua using the socket.http module. The question lies here. Previously, youtube pages led me to

相关标签:
2条回答
  • 2021-01-23 03:37

    I believe this line should be changed:

     header = { host= "youtube.com" }
    

    To:

     header = { host= "www.youtube.com" }
    

    After that, works for me.

    0 讨论(0)
  • 2021-01-23 03:43

    The solution is to install luasec and to use ssl.https module to do the request.

    Answered here by Paul Kulchenko!

    Example:

    -- luasec version 0.4.2
    require("ssl")
    require("https")
    -- ssl.https.request(...)
    
    0 讨论(0)
提交回复
热议问题