-
Notifications
You must be signed in to change notification settings - Fork 2
Don't read body, just set the Content-Length
header
#68
base: master
Are you sure you want to change the base?
Conversation
As said, I've tested this locally (commenting out the authentication logic) and it seems to work but I'd like to try and use this proxy version in front of my RStudio instance and see if it works as expected. |
app/proxy.js
Outdated
@@ -8,12 +8,12 @@ var proxy = httpProxy.createProxyServer(config.proxy); | |||
|
|||
proxy.on('proxyReq', function (proxyReq, req, res, options) { | |||
proxyReq.setHeader('Cookie', insert_auth_cookie(req)); | |||
proxy_body(req, proxyReq); | |||
set_content_lenght(req, proxyReq); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
length?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling mistake but otherwise fine, give it a go
We used to read the request body to calculate the `Content-Length`, we now just copy the velue of the `Content-Length` header. The request body is proxied by default, as you'd expect. Tested locally against a running RStudio container and it seems to work. I've uploaded a 37MB ISO image and checked the MD5 of the file uploaded against the checksum of the original file and the file was uploaded without corruption. **NOTE**: This is to simplify the `rstudio-proxy` logic before moving into the other `auth-proxy`. Part of ticket: https://trello.com/c/5twZHrb4/215-try-to-replace-custom-rstudio-auth-proxy-with-our-usual-generic-one
(rebased on top of changes Ravi merged yesterday) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. I'm not sure it really needs to be in a separate function, since the level of abstraction is the same (ie, both the callback and set_content_length()
are setting headers on proxyReq
), but that's not really a problem.
@andyhd I was actually thinking about that as the function become so simple but I left as function to not have duplication. But I have a better idea, move the |
- both `proxyReq` and `proxyReqWs` were doing the same thing. these events are now handled by the same function - removed a layer of indirection in the logic that set the `Cookie` header and using some constants to make what's happening more explicit - export `auth.secureCookie()` as `auth.secureCookie()`, having different names here doesn't add any value and it can be confusing (I was always finding it confusing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, nice
FYI: I've tried to use this proxy in front of my RStudio instance and it seems to work fine (tested upload of 37MB file and also to run the usual Shiny App in the viewer). |
We used to read the request body to calculate the
Content-Length
,we now just copy the velue of the
Content-Length
header.The request body is proxied by default, as you'd expect.
Tested locally against a running RStudio container and it seems to
work. I've uploaded a 37MB ISO image and checked the MD5 of the file
uploaded against the checksum of the original file and the file was
uploaded without corruption.
NOTE: This is to simplify the
rstudio-proxy
logic before moving itinto the other
auth-proxy
.Part of ticket: https://trello.com/c/5twZHrb4/215-try-to-replace-custom-rstudio-auth-proxy-with-our-usual-generic-one