我试图在vala中对汤的HTTP GET请求使用汤,但始终返回状态代码6,在清单文件中,我具有“ --share = network”权限
我不知道问题出在哪里,如果我需要额外的权限来发出服务器请求,或者这是Flatpak安全的一部分?
// Vala code
var session = new Soup.Session();
var uri = "https://jsonplaceholder.typicode.com/todos/var message = new Soup.Message ("GET",session.queue_message (message, (sess, mess) =>
// Process the result:
print ("Status Code: %u\n", mess.status_code);
print ("Message length: %lld\n", mess.response_body.length);
}
// Manifest file
{
"app-id": "com.github.calo001.fondo",
"base": "io.elementary.
"base-version": "juno",
"runtime": "org.freedesktop.Platform",
"sdk": "org.freedesktop.Sdk",
"runtime-version": "18.08",
"command": "com.github.calo001.fondo",
"finish-args": [
/* X11 + XShm */
"--share=ipc", "--socket=x11",
/* Wayland */
"--socket=wayland",
/* Network */
"--share=network",
/* dconf */
"--filesystem=xdg-run/dconf", "--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf", "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],
"modules": [
{
"name": "fondo",
"buildsystem": "meson",
"config-opts": ["--buildtype=release"],
"sources":[
{
"type": "git",
"url": "https://github.com/calo001/fondo.git"
}
]
}
]
}
答案 0 :(得分:0)
在soup-status.h中,状态码6为SOUP_STATUS_SSL_FAILED
。因此,首先要尝试使用http
而不是https
。顺便说一下,您的Soup.Message
示例正在显示"POST"
,但是您说您正在尝试发出GET请求。您还可以使用Soup.Message.get_https_status
来获取有关HTTPS请求失败的更多详细信息。