小编Alg*_*thm的帖子

301 与 socket.http 永久移动

在 python(和我的浏览器)中,我能够https://www.devrant.com/api/devrant/rants?app=3&sort=algo&limit=10&skip=0按预期向其发送请求并获得响应,但使用 Lua,我得到HTTP/1.1 301 Moved Permanently. 这是我迄今为止尝试过的:

http = require("socket.http");
print(http.request("https://www.devrant.com/api/devrant/rants?app=3&sort=algo&limit=10&skip=0")
Run Code Online (Sandbox Code Playgroud)

它输出一个 HTTP 错误页面(永久移动)和

301    table: 0x8f32470    http/1.1 301 Moved Permanently
Run Code Online (Sandbox Code Playgroud)

该表的内容是:

location    https://www.devrant.com/api/devrant/rants?app=3&sort=algo&limit=10&skip=0
content-type    text/html
server    nginx/1.10.0 (Ubuntu)
content-length    194
connection    close
date    Mon, 11 Dec 2017 01:41:35
Run Code Online (Sandbox Code Playgroud)

为什么只有 Lua 会出现这个错误?如果我向 google 请求,我会得到 google 主页 HTML。如果我请求 status.mojang.com,我会在 JSON 响应字符串中获取 mojang 服务器状态,因此套接字肯定可以正常工作。

sockets lua http

3
推荐指数
1
解决办法
1163
查看次数

Lua c lib Windows:找不到指定的程序

我的机器上安装了 Lua 5.3.5 64 位。我正在编译一个64位dll来测试c api进程。这是我的文件driver.c

#define LUA_LIB

#include "lua/lua.h"
#include "lua/lualib.h"
#include "lua/lauxlib.h"

static int returnone(lua_State *L) {
    return 1;
}

static const luaL_Reg lualib[] = {
    {"returnone", returnone},
    {NULL, NULL}
};

int luaopen_lualib(lua_State *L) {
    luaL_newlib(L, lualib);
    return 1;
}
Run Code Online (Sandbox Code Playgroud)

这输出到lualib.dll

我创建了一个脚本,test.lualualib.dll.

require("lualib");
Run Code Online (Sandbox Code Playgroud)

我明白了:

$ lua.exe test.lua
C:\Program Files\Lua\lua.exe: error loading module 'lualib' from file '.\lualib.dll':
        The specified procedure could not be found.

stack traceback:
        [C]: in ?
        [C]: …
Run Code Online (Sandbox Code Playgroud)

c windows lua

2
推荐指数
1
解决办法
1339
查看次数

标签 统计

lua ×2

c ×1

http ×1

sockets ×1

windows ×1