每次404,SHOUTcast提取请求均被拒绝 [英] SHOUTcast fetch request denied every time with 404

查看:134
本文介绍了每次404,SHOUTcast提取请求均被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function radiotest(host,port)
    local rstr="Online"
    local sock, err = socket.tcp()
    if not sock then
        return "Failed"
    end
    sock:settimeout(1)
    local res, err = sock:connect(host, port)
    if not res then
        return "offline"
    else
        sock:settimeout(1)
        sock:send("GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status \r\n Accept: */*\r\n\r\n")
        sock:settimeout(3)
        local data=sock:receive('*a')
        sock:close()
        print(data)
        -- Further processing content here
    end
end
print( radiotest( "10.*.*.*", 1234 ) )

上面的套接字连接返回了我:

The above socket connection returns me:

ICY 404 Resource Not Found
icy-notice1:<BR>SHOUTcast Distributed Network Audio Server/win32 v1.9.7<BR>
icy-notice2:The resource requested was not found<BR>

我认为问题出在我的标题列表中,但我无法跟踪它.

I think the problem is in my headers listing, but I'm unable to trace it.

该页面在所有浏览器中都可以正常打开(Opera确实需要屏蔽为其他浏览器;否则,它将继续下载所有歌曲).

The page opens fine in all browsers(Opera does need to be masked as another browser; otherwise it just keeps on downloading all songs).

我尝试在sock:send()

  • GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n
  • GET /index.html HTTP/1.0\r\n UserAgent: Opera/9.80 (Windows NT 6.1; Win64; x64) Presto/2.12.388 Version/12.12\r\n\r\n
  • GET /index.html HTTP/1.0\r\n UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17\r\n\r\n
  • GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n
  • GET /index.html HTTP/1.0\r\n UserAgent: Opera/9.80 (Windows NT 6.1; Win64; x64) Presto/2.12.388 Version/12.12\r\n\r\n
  • GET /index.html HTTP/1.0\r\n UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17\r\n\r\n

我完全被这部分困住了.如何使用socket.tcp()获取页面?

I'm totally stuck at this part. How do I fetch the page using socket.tcp()?

推荐答案

@Brad谢谢.您对Wireshark的帮助确实是切实可行的.由于我在请求中提供了额外的空间,因此未将User-Agent标头传递给服务器.

@Brad Thanks. Your help with Wireshark was indeed practicable. The User-Agent header was not being passed to the server because of an extra space I was providing in the request.

sock:send("GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status \r\n Accept: */*\r\n\r\n")

\r\n UserAgent: SHOUTcast Song Status应该改为:

\r\nUser-Agent: SHOUTcast Song Status

现在工作正常.

感谢您的帮助. :D

Thanks for the help. :D

过滤掉HTML后,该函数的结果如下:

The results from the function after filtering out the HTML is like:

在线(补语-如果您只能看到)

Online(Tonic - If You Could Only See)

在线(补语-如果您只能看到),流以256 kbps的速度进行监听,其中32个侦听器中有0个(唯一的0个)

Online(Tonic - If You Could Only See) Stream is up at 256 kbps with 0 of 32 listeners (0 unique)

这篇关于每次404,SHOUTcast提取请求均被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆