(alt, originOrStream)
| 1725 | // the origin. alt is a string containing the altsvc details. No fancy |
| 1726 | // API is provided for that. |
| 1727 | altsvc(alt, originOrStream) { |
| 1728 | if (this.destroyed) |
| 1729 | throw new ERR_HTTP2_INVALID_SESSION(); |
| 1730 | |
| 1731 | let stream = 0; |
| 1732 | let origin; |
| 1733 | |
| 1734 | if (typeof originOrStream === 'string') { |
| 1735 | origin = getURLOrigin(originOrStream); |
| 1736 | if (origin === 'null') |
| 1737 | throw new ERR_HTTP2_ALTSVC_INVALID_ORIGIN(); |
| 1738 | } else if (typeof originOrStream === 'number') { |
| 1739 | if (originOrStream >>> 0 !== originOrStream || originOrStream === 0) { |
| 1740 | throw new ERR_OUT_OF_RANGE('originOrStream', |
| 1741 | `> 0 && < ${2 ** 32}`, originOrStream); |
| 1742 | } |
| 1743 | stream = originOrStream; |
| 1744 | } else if (originOrStream !== undefined) { |
| 1745 | // Allow origin to be passed a URL or object with origin property |
| 1746 | if (originOrStream !== null && typeof originOrStream === 'object') |
| 1747 | origin = originOrStream.origin; |
| 1748 | // Note: if originOrStream is an object with an origin property other |
| 1749 | // than a URL, then it is possible that origin will be malformed. |
| 1750 | // We do not verify that here. Users who go that route need to |
| 1751 | // ensure they are doing the right thing or the payload data will |
| 1752 | // be invalid. |
| 1753 | if (typeof origin !== 'string') { |
| 1754 | throw new ERR_INVALID_ARG_TYPE('originOrStream', |
| 1755 | ['string', 'number', 'URL', 'object'], |
| 1756 | originOrStream); |
| 1757 | } else if (origin === 'null' || origin.length === 0) { |
| 1758 | throw new ERR_HTTP2_ALTSVC_INVALID_ORIGIN(); |
| 1759 | } |
| 1760 | } |
| 1761 | |
| 1762 | validateString(alt, 'alt'); |
| 1763 | if (!kQuotedString.test(alt)) |
| 1764 | throw new ERR_INVALID_CHAR('alt'); |
| 1765 | |
| 1766 | // Max length permitted for ALTSVC |
| 1767 | if ((alt.length + (origin !== undefined ? origin.length : 0)) > kMaxALTSVC) |
| 1768 | throw new ERR_HTTP2_ALTSVC_LENGTH(); |
| 1769 | |
| 1770 | this[kHandle].altsvc(stream, origin || '', alt); |
| 1771 | } |
| 1772 | |
| 1773 | // Submits an origin frame to be sent. |
| 1774 | origin(...origins) { |
no test coverage detected