没有FastRWeb的Rserve .http.request函数

时间:2016-03-28 22:41:14

标签: http nginx rserve

我正在尝试直接在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原样:

remote enable http.port 6312

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

1 个答案:

答案 0 :(得分:0)

我不确定我是否理解这与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相关的问题。