Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All requests on a TCP connection share a global, mutable scope #49

Closed
trestletech opened this issue Jun 16, 2015 · 1 comment
Closed

Comments

@trestletech
Copy link

Any modifications to the req object persist across separate HTTP requests. If you run the following and hit it from the same browser, you'll see the counter increment.

I suppose there are benefits to this, but it seems unexpected when compared to e.g. Express.

httpuv::runServer("0.0.0.0", 3000,list(
  call = function(req){
    if (is.null(req$counter)){
      req$counter <- 0
    }
    req$counter <- req$counter + 1
    print(req$counter)

    list(
      status= 200L,
      headers = list(
        'Content-type' = 'text/html'
      ), body = "hi there"
    )
  }, onHeaders = function(req){
    NULL
  }, onWSOpen = function(ws){
    NULL
  }
))
@wch
Copy link
Collaborator

wch commented Apr 13, 2018

This now works correctly on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants