summaryrefslogtreecommitdiff
path: root/src/node_http2.cc
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-07-22 09:20:53 -0700
committerJames M Snell <jasnell@gmail.com>2017-08-04 12:56:45 -0700
commitd6a774b1bd2c7ccbd783b06a95f6eeeb8dca210c (patch)
treea8d698a4f64643da65240917cb971c9377a1575b /src/node_http2.cc
parent953458f645697fee420a2bb5e24038f3a7bc44df (diff)
downloadandroid-node-v8-d6a774b1bd2c7ccbd783b06a95f6eeeb8dca210c.tar.gz
android-node-v8-d6a774b1bd2c7ccbd783b06a95f6eeeb8dca210c.tar.bz2
android-node-v8-d6a774b1bd2c7ccbd783b06a95f6eeeb8dca210c.zip
http2: add range support for respondWith{File|FD}
* respondWithFD now supports optional statCheck * respondWithFD and respondWithFile both support offset/length for range requests * Fix linting nits following most recent update PR-URL: https://github.com/nodejs/node/pull/14239 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rwxr-xr-xsrc/node_http2.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 61a98758b1..ee12072939 100755
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -604,7 +604,9 @@ void Http2Session::SubmitResponse(const FunctionCallbackInfo<Value>& args) {
void Http2Session::SubmitFile(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsNumber()); // Stream ID
CHECK(args[1]->IsNumber()); // File Descriptor
- CHECK(args[2]->IsArray()); // Headers
+ CHECK(args[2]->IsArray()); // Headers
+ CHECK(args[3]->IsNumber()); // Offset
+ CHECK(args[4]->IsNumber()); // Length
Http2Session* session;
Nghttp2Stream* stream;
@@ -618,6 +620,11 @@ void Http2Session::SubmitFile(const FunctionCallbackInfo<Value>& args) {
int fd = args[1]->Int32Value(context).ToChecked();
Local<Array> headers = args[2].As<Array>();
+ int64_t offset = args[3]->IntegerValue(context).ToChecked();
+ int64_t length = args[4]->IntegerValue(context).ToChecked();
+
+ CHECK_GE(offset, 0);
+
DEBUG_HTTP2("Http2Session: submitting file %d for stream %d: headers: %d, "
"end-stream: %d\n", fd, id, headers->Length());
@@ -627,7 +634,8 @@ void Http2Session::SubmitFile(const FunctionCallbackInfo<Value>& args) {
Headers list(isolate, context, headers);
- args.GetReturnValue().Set(stream->SubmitFile(fd, *list, list.length()));
+ args.GetReturnValue().Set(stream->SubmitFile(fd, *list, list.length(),
+ offset, length));
}
void Http2Session::SendHeaders(const FunctionCallbackInfo<Value>& args) {