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

Commit ce4c08d

Browse files
committed
http2: additional doc
PR-URL: #181 Reviewed-By: Matteo Collina <[email protected]>
1 parent a8cd3ce commit ce4c08d

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
lines changed

doc/api/errors.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,190 @@ Used for status codes outside the regular status code ranges (100-999).
614614
Used when the `Trailer` header is set even though the transfer encoding does not
615615
support that.
616616

617+
<a id="ERR_HTTP2_CONNECT_AUTHORITY"></a>
618+
### ERR_HTTP2_CONNECT_AUTHORITY
619+
620+
For HTTP/2 requests using the `CONNECT` method, the `:authority` pseudo-header
621+
is required.
622+
623+
<a id="ERR_HTTP2_CONNECT_PATH"></a>
624+
### ERR_HTTP2_CONNECT_PATH
625+
626+
For HTTP/2 requests using the `CONNECT` method, the `:path` pseudo-header is
627+
forbidden.
628+
629+
<a id="ERR_HTTP2_CONNECT_SCHEME"></a>
630+
### ERR_HTTP2_CONNECT_SCHEME
631+
632+
The HTTP/2 requests using the `CONNECT` method, the `:scheme` pseudo-header is
633+
forbidden.
634+
635+
<a id="ERR_HTTP2_ERROR"></a>
636+
### ERR_HTTP2_ERROR
637+
638+
A non-specific HTTP/2 error has occurred.
639+
640+
<a id="ERR_HTTP2_FRAME_ERROR"></a>
641+
### ERR_HTTP2_FRAME_ERROR
642+
643+
Used when a failure occurs sending an individual frame on the HTTP/2
644+
session.
645+
646+
<a id="ERR_HTTP2_HEADERS_OBJECT"></a>
647+
### ERR_HTTP2_HEADERS_OBJECT
648+
649+
Used when an HTTP/2 Headers Object is expected.
650+
651+
<a id="ERR_HTTP2_HEADERS_SENT"></a>
652+
### ERR_HTTP2_HEADERS_SENT
653+
654+
Used when an attempt is made to send multiple response headers.
655+
656+
<a id="ERR_HTTP2_HEADER_SINGLE_VALUE"></a>
657+
### ERR_HTTP2_HEADER_SINGLE_VALUE
658+
659+
Used when multiple values have been provided for an HTTP header field that
660+
required to have only a single value.
661+
662+
<a id="ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND"></a>
663+
### ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND
664+
665+
HTTP/2 Informational headers must only be sent *prior* to calling the
666+
`Http2Stream.prototype.respond()` method.
667+
668+
<a id="ERR_HTTP2_INFO_STATUS_NOT_ALLOWED"></a>
669+
### ERR_HTTP2_INFO_STATUS_NOT_ALLOWED
670+
671+
Informational HTTP status codes (`1xx`) may not be set as the response status
672+
code on HTTP/2 responses.
673+
674+
<a id="ERR_HTTP2_INVALID_CONNECTION_HEADERS"></a>
675+
### ERR_HTTP2_INVALID_CONNECTION_HEADERS
676+
677+
HTTP/1 connection specific headers are forbidden to be used in HTTP/2
678+
requests and responses.
679+
680+
<a id="ERR_HTTP2_INVALID_HEADER_VALUE"></a>
681+
### ERR_HTTP2_INVALID_HEADER_VALUE
682+
683+
Used to indicate that an invalid HTTP/2 header value has been specified.
684+
685+
<a id="ERR_HTTP2_INVALID_INFO_STATUS"></a>
686+
### ERR_HTTP2_INVALID_INFO_STATUS
687+
688+
An invalid HTTP informational status code has been specified. Informational
689+
status codes must be an integer between `100` and `199` (inclusive).
690+
691+
<a id="ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH"></a>
692+
693+
Input `Buffer` and `Uint8Array` instances passed to the
694+
`http2.getUnpackedSettings()` API must have a length that is a multiple of
695+
six.
696+
697+
<a id="ERR_HTTP2_INVALID_PSEUDOHEADER"></a>
698+
### ERR_HTTP2_INVALID_PSEUDOHEADER
699+
700+
Only valid HTTP/2 pseudoheaders (`:status`, `:path`, `:authority`, `:scheme`,
701+
and `:method`) may be used.
702+
703+
<a id="ERR_HTTP2_INVALID_SESSION"></a>
704+
### ERR_HTTP2_INVALID_SESSION
705+
706+
Used when any action is performed on an `Http2Session` object that has already
707+
been destroyed.
708+
709+
<a id="ERR_HTTP2_INVALID_SETTING_VALUE"></a>
710+
### ERR_HTTP2_INVALID_SETTING_VALUE
711+
712+
An invalid value has been specified for an HTTP/2 setting.
713+
714+
<a id="ERR_HTTP2_INVALID_STREAM"></a>
715+
### ERR_HTTP2_INVALID_STREAM
716+
717+
Used when an operation has been performed on a stream that has already been
718+
destroyed.
719+
720+
<a id="ERR_HTTP2_MAX_PENDING_SETTINGS_ACK"></a>
721+
### ERR_HTTP2_MAX_PENDING_SETTINGS_ACK
722+
723+
Whenever an HTTP/2 `SETTINGS` frame is sent to a connected peer, the peer is
724+
required to send an acknowledgement that it has received and applied the new
725+
SETTINGS. By default, a maximum number of un-acknowledged `SETTINGS` frame may
726+
be sent at any given time. This error code is used when that limit has been
727+
reached.
728+
729+
<a id="ERR_HTTP2_OUT_OF_STREAMS"></a>
730+
### ERR_HTTP2_OUT_OF_STREAMS
731+
732+
Used when the maximum number of streams on a single HTTP/2 session have been
733+
created.
734+
735+
<a id="ERR_HTTP2_PAYLOAD_FORBIDDEN"></a>
736+
### ERR_HTTP2_PAYLOAD_FORBIDDEN
737+
738+
Used when a message payload is specified for an HTTP response code for which
739+
a payload is forbidden.
740+
741+
<a id="ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED"></a>
742+
### ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED
743+
744+
Used to indicate that an HTTP/2 pseudo-header has been used inappropriately.
745+
Pseudo-headers are header key names that begin with the `:` prefix.
746+
747+
<a id="ERR_HTTP2_PUSH_DISABLED"></a>
748+
### ERR_HTTP2_PUSH_DISABLED
749+
750+
Used when push streams have been disabled by the client but an attempt to
751+
create a push stream is made.
752+
753+
<a id="ERR_HTTP2_SEND_FILE"></a>
754+
### ERR_HTTP2_SEND_FILE
755+
756+
Used when an attempt is made to use the
757+
`Http2Stream.prototype.responseWithFile()` API to send a non-regular file.
758+
759+
<a id="ERR_HTTP2_SOCKET_BOUND"></a>
760+
### ERR_HTTP2_SOCKET_BOUND
761+
762+
Used when an attempt is made to connect a `Http2Session` object to a
763+
`net.Socket` or `tls.TLSSocket` that has already been bound to another
764+
`Http2Session` object.
765+
766+
<a id="ERR_HTTP2_STATUS_101"></a>
767+
### ERR_HTTP2_STATUS_101
768+
769+
Use of the `101` Informational status code is forbidden in HTTP/2.
770+
771+
<a id="ERR_HTTP2_STATUS_INVALID"></a>
772+
### ERR_HTTP2_STATUS_INVALID
773+
774+
An invalid HTTP status code has been specified. Status codes must be an integer
775+
between `100` and `599` (inclusive).
776+
777+
<a id="ERR_HTTP2_STREAM_CLOSED"></a>
778+
### ERR_HTTP2_STREAM_CLOSED
779+
780+
Used when an action has been performed on an HTTP/2 Stream that has already
781+
been closed.
782+
783+
<a id="ERR_HTTP2_STREAM_ERROR"></a>
784+
### ERR_HTTP2_STREAM_ERROR
785+
786+
Used when a non-zero error code has been specified in an RST_STREAM frame.
787+
788+
<a id="ERR_HTTP2_STREAM_SELF_DEPENDENCY"></a>
789+
### ERR_HTTP2_STREAM_SELF_DEPENDENCY
790+
791+
When setting the priority for an HTTP/2 stream, the stream may be marked as
792+
a dependency for a parent stream. This error code is used when an attempt is
793+
made to mark a stream and dependent of itself.
794+
795+
<a id="ERR_HTTP2_UNSUPPORTED_PROTOCOL"></a>
796+
### ERR_HTTP2_UNSUPPORTED_PROTOCOL
797+
798+
Used when `http2.connect()` is passed a URL that uses any protocol other than
799+
`http:` or `https:`.
800+
617801
<a id="ERR_INDEX_OUT_OF_RANGE"></a>
618802
### ERR_INDEX_OUT_OF_RANGE
619803

doc/api/http2.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,26 @@ These will be reported using either a synchronous `throw` or via an `'error'`
15871587
event on the `Http2Stream`, `Http2Session` or HTTP/2 Server objects, depending
15881588
on where and when the error occurs.
15891589

1590+
### Push streams on the client
1591+
1592+
To receive pushed streams on the client, set a listener for the `'stream'`
1593+
event on the `ClientHttp2Session`:
1594+
1595+
```js
1596+
const http2 = require('http2');
1597+
1598+
const client = http2.connect('http://localhost');
1599+
1600+
client.on('stream', (pushedStream, requestHeaders) => {
1601+
pushedStream.on('push', (responseHeaders) => {
1602+
// process response headers
1603+
});
1604+
pushedStream.on('data', (chunk) => { /* handle pushed data */ });
1605+
});
1606+
1607+
const req = client.request({ ':path': '/' });
1608+
```
1609+
15901610
### Supporting the CONNECT method
15911611

15921612
The `CONNECT` method is used to allow an HTTP/2 server to be used as a proxy

0 commit comments

Comments
 (0)