使用 Flatpak 在 vala building 中使用 libsoup 发出获取请求
Make get requests with libsoup in vala building with Flatpak
我正在尝试在 vala 中使用 soup 进行 http GET 请求,但总是 return 状态代码 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"
}
]
}
]
}
从 soup-status.h status code 6 is SOUP_STATUS_SSL_FAILED
. So the first thing to try would be using http
instead of https
. By the way your Soup.Message
sample is showing "POST"
, but you say you are trying to make a GET request. You could also use Soup.Message.get_https_status
获取有关 HTTPS 请求失败的更多详细信息。
我正在尝试在 vala 中使用 soup 进行 http GET 请求,但总是 return 状态代码 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"
}
]
}
]
}
从 soup-status.h status code 6 is SOUP_STATUS_SSL_FAILED
. So the first thing to try would be using http
instead of https
. By the way your Soup.Message
sample is showing "POST"
, but you say you are trying to make a GET request. You could also use Soup.Message.get_https_status
获取有关 HTTPS 请求失败的更多详细信息。