rstudio / httpuv

HTTP and WebSocket server package for R
Other
229 stars 86 forks source link

Allow headers to be NULL or an unnamed list #289

Closed wch closed 3 years ago

wch commented 3 years ago

Previously, headers had to be a named list. In order to have no headers (besides the ones httpuv adds automatically), headers would have to be an empty named list, which is a little awkward to create. With this change, headers can be NULL, list() (an empty unnamed list), or it can be unset.

For example, this app would not work before, but it does now:

s <- startServer("127.0.0.1", 5000,
  list(
    call = function(req) {
      list(
        status = 200L,
        headers = list(),
        body = ""
      )
    }
  )
)

The result:

$ curl -i http://localhost:5000
HTTP/1.1 200 OK
Date: Thu, 26 Nov 2020 16:33:55 GMT
Content-Length: 0
atheriel commented 3 years ago

This fixes #195.

wch commented 3 years ago

Thanks, I forgot about that issue. I've updated the NEWS to refer to it.