Make sure connection is not upgraded too early #162
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #161. This makes sure that a HTTP connection is not upgraded too early, before all the request headers have been processed.
In the old http-parser code,
parser->upgrade
was set in thes_headers_almost_done
stage (https://github.com/rstudio/httpuv/blob/v1.3.6.2/src/http-parser/http_parser.c#L1567-L1568). This happens when all the request headers have been processed.Also, in the current version of http-parser,
parser->upgrade
is set ins_headers_almost_done
(https://github.com/rstudio/httpuv/blob/c3978bad/src/http-parser/http_parser.c#L1822-L1825) or ins_on_headers_completed
(https://github.com/rstudio/httpuv/blob/c3978bad/src/http-parser/http_parser.c#L1884).In #153, we added
isUpgrade()
. The problem is that it could returntrue
before all the headers have been processed. This PR makes sure thatisUpgrade()
will returntrue
only after all the headers have been processed.One thing that I'm not 100% sure about: In the http-parser code,
parser->upgrade
could be set in a slightly earlier stage (s_headers_almost_done
) than what I've done here (HttpRequest:: _on_headers_complete
), and I wonder if that could result in different behavior.Testing notes
install.packages("shiny")
). The httpuv version from CRAN should be 1.4.4.2; if that's not whatpackageVersion("httpuv")
gives you, theninstall.packages("httpuv")
as well.shiny::runExample("01_hello")
You should see it grey out. If not, try reloading the app (not the IDE) a few times.
Then install httpuv from GitHub (
devtools::install_github("rstudio/httpuv")
) and restart R, and try to repro again. It should no longer grey out.