rapache icon indicating copy to clipboard operation
rapache copied to clipboard

RApache passes NULL for empty GET parameters

Open viking opened this issue 10 years ago • 3 comments

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.

viking avatar Dec 18 '13 17:12 viking

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')

viking avatar Dec 18 '13 17:12 viking

Yes, that is inconsistent. How about an R level option, say options(rapache.formvars.default.value='') help?

jeffreyhorner avatar Dec 18 '13 17:12 jeffreyhorner

Or, it could just default to using empty strings for Rook apps.

jeffreyhorner avatar Dec 18 '13 17:12 jeffreyhorner