gpt4 book ai didi

http - 没有 FastRWeb 的 Rserve .http.request 函数

转载 作者:可可西里 更新时间:2023-11-01 17:07:22 26 4
gpt4 key购买 nike

我正在尝试直接在 Rserve (HTTP) 前面设置 nginx。 Rserve 1.7.0 发行说明 ( http://www.rforge.net/Rserve/news.html ) 建议您需要定义 .http.request 辅助函数。我遇到的每个示例都建议将这些行添加到 Rserv.conf,但我不想使用 FastRWeb。

library(FastRWeb)
.http.request <- FastRWeb:::.http.request

我的 Rserve.conf 原样:

远程启用
http.端口 6312

你能帮我实现一个不依赖于 FastRWeb 的 .http.request 吗?谢谢!

最佳答案

我不确定我是否理解这与 nginx 有何关系,因为它仅充当反向代理,因此不需要更改 Rserve 配置。

但是 .http.request 必须只是一个定义为的函数

.http.request <- function(url, query, body, headers, ...)

您可以做任何您想做的事,然后返回以下内容(引用自 Rserve):

       the result is expected to have one of the following forms:             

a) character vector of length 1 => error (possibly from try),
will create 500 response

b) list(payload[, content-type[, headers[, status code]]])

payload: can be a character vector of length one or a
raw vector. if the character vector is named "file" then
the content of a file of that name is the payload

content-type: must be a character vector of length one
or NULL (if present, else default is "text/html")

headers: must be a character vector - the elements will
have CRLF appended and neither Content-type nor
Content-length may be used

status code: must be an integer if present (default is 200)

只有负载是强制性的,其他都是可选的。将您的代码包装在类似 tryCatch({ ... }, error=function(e) e$message) 的内容中是个好主意,这样您就可以在失败的情况下看到输出。

请注意,这与 R 中内置的 HTTP 服务器使用的 API 相同。

PS:请考虑使用 stats-rosuda-devel Rserve 相关问题的邮件列表。

关于http - 没有 FastRWeb 的 Rserve .http.request 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36272427/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com