rapache
rapache copied to clipboard
RApache passes NULL for empty GET parameters
If you make a GET request with a query string like this: ?foo=&bar=123
, Rook's req$GET() returns a list with NULL values in it when running under RApache: list(foo = NULL, bar = "123")
. When running in R interactively with Rhttpd, req$GET() returns a list with empty strings: list(foo = "", bar = "123)
. The behavior is inconsistent.
Here's the code I used to test Rook using Rhttpd:
library(Rook)
app <- function(env) {
req <- Request$new(env)
res <- Response$new()
vars <- capture.output(print(req$GET()))
res$write(c("<pre>", paste(vars, collapse = "\n"), "</pre>"))
res$finish()
}
s <- Rhttpd$new()
s$start(port = 12345)
s$add(app, 'foo')
Yes, that is inconsistent. How about an R level option, say options(rapache.formvars.default.value='') help?
Or, it could just default to using empty strings for Rook apps.