Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Commit

Permalink
http2: add http2stream.respondWithFile()
Browse files Browse the repository at this point in the history
Adds a new `http2stream.respondWithFile()` method that allows
sending a file in response without having to go through the
streams mechanism. All of the file i/o happens in the native
layer.

PR-URL: #164
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
jasnell committed Jul 2, 2017
1 parent 8ae3b01 commit 8f7d9c7
Show file tree
Hide file tree
Showing 25 changed files with 1,093 additions and 170 deletions.
331 changes: 322 additions & 9 deletions doc/api/http2.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ E('ERR_HTTP2_CONNECT_PATH',
'The :path header is forbidden for CONNECT requests');
E('ERR_HTTP2_CONNECT_SCHEME',
'The :scheme header is forbidden for CONNECT requests');
E('ERR_HTTP2_FRAME_ERROR',
(type, code, id) => {
let msg = `Error sending frame type ${type}`;
if (id !== undefined)
msg += ` for stream ${id}`;
msg += ` with code ${code}`;
return msg;
});
E('ERR_HTTP2_HEADER_REQUIRED',
(name) => `The ${name} header is required`);
E('ERR_HTTP2_HEADER_SINGLE_VALUE',
Expand All @@ -152,17 +160,22 @@ E('ERR_HTTP2_INVALID_SETTING_VALUE',
(name, value) => `Invalid value for setting "${name}": ${value}`);
E('ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
(max) => `Maximum number of pending settings acknowledgements (${max})`);
E('ERR_HTTP2_PAYLOAD_FORBIDDEN',
(code) => `Responses with ${code} status must not have a payload`);
E('ERR_HTTP2_OUT_OF_STREAMS',
'No stream ID is available because maximum stream ID has been reached');
E('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED', 'Cannot set HTTP/2 pseudo-headers');
E('ERR_HTTP2_PUSH_DISABLED', 'HTTP/2 client has disabled push streams');
E('ERR_HTTP2_SEND_FILE', 'Only regular files can be sent');
E('ERR_HTTP2_SOCKET_BOUND',
'The socket is already bound to an Http2Session');
E('ERR_HTTP2_STATUS_INVALID',
(code) => `Invalid status code: ${code}`);
E('ERR_HTTP2_STATUS_101',
'HTTP status code 101 (Switching Protocols) is forbidden in HTTP/2');
E('ERR_HTTP2_STREAM_CLOSED', 'The stream is already closed');
E('ERR_HTTP2_STREAM_ERROR',
(code) => `Stream closed with error code ${code}`);
E('ERR_HTTP2_STREAM_SELF_DEPENDENCY', 'A stream cannot depend on itself');
E('ERR_HTTP2_UNSUPPORTED_PROTOCOL',
(protocol) => `protocol "${protocol}" is unsupported.`);
Expand Down
Loading

0 comments on commit 8f7d9c7

Please sign in to comment.