You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When request headers are large, they can get truncated.
Example:
library(httpuv)
# Create a web server app which returns the value of "test-header".handle_headers<-function(req) {
str(as.list(req))
message("headers")
}
handle_request<-function(req) {
# Store the headers in a global var named z, for inspection later.z<<-req$HEADERSlist(
status=200L,
headers=list('Content-Type'='text/plain'),
# Use paste0("", ...) in case the header is NULLbody= paste0("", req$HTTP_TEST_HEADER)
)
}
s<-httpuv::startServer("0.0.0.0", 5000,
list(
onHeaders=function(req) handle_headers(req),
call=function(req) handle_request(req)
)
)
# Request a URL from the local web appfetch<-function(url, headers=list()) {
h<-curl::new_handle()
do.call(curl::handle_setheaders, c(list(h), headers))
# Make the requestx<-NULLcurl::curl_fetch_multi(
url,
handle=h,
done=function(res) { x<<-res },
fail=function(msg) {
x<<-FALSE
message("Failed: ", msg)
}
)
# Pump both the curl and httpuv/later event loops until the download is finished.while (is.null(x)) {
curl::multi_run(0)
later::run_now()
}
x
}
# ===============================# Create a request with a large header (81000 bytes)long_string<- paste0(rep(".", 81000), collapse="")
x<- fetch("http://127.0.0.1:5000", list("test-header"=long_string))
content<- rawToChar(x$content)
nchar(content)
#> [1] 65380
identical(content, long_string)
#> [1] FALSE
The headers are stored in z. If you inspect them, there's a header named "" which has the remaining part of the header. Adding up the sizes of "test-header" and "", we get the original header size, which is 81000.
The problem is that the HttpRequest::_on_header_value callback (which is invoked by the http parser) assumes that it will only be called once per value, but that's not necessarily true.:
One more note: We should also consider increasing the HTTP_MAX_HEADER_SIZE for http-parser. We're currently using the default of 80kB, but there may be cases where a larger value is needed.
When request headers are large, they can get truncated.
Example:
The headers are stored in
z
. If you inspect them, there's a header named""
which has the remaining part of the header. Adding up the sizes of"test-header"
and""
, we get the original header size, which is 81000.@aronatkins also provided a Python test app, which splits up the HTTP request into small TCP messages.
Details
The text was updated successfully, but these errors were encountered: