Skip to content

Commit

Permalink
feat(http1): Added support for transparent HTTP/1(.1)
Browse files Browse the repository at this point in the history
Both unencrypted (http) and encrypted (https) is supported for both HTTP/1(.1) and HTTP/2. For
https, fetch-h2 will use ALPN to negotiate version.

BREAKING CHANGE: "http://" will default to HTTP/1(.1) rather than HTTP/2
  • Loading branch information
grantila committed Jan 13, 2019
1 parent 8336256 commit 69b56d0
Show file tree
Hide file tree
Showing 27 changed files with 2,647 additions and 1,008 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Regardless of whether you're actually interested in the Fetch API per se or not,

By default, `fetch-h2` will accept `gzip` and `deflate` encodings, and decode transparently. If you also want to allow Brotli (`br`), use the [`fetch-h2-br`](https://www.npmjs.com/package/fetch-h2-br) package.

**NOTE;** HTTP/2 support was introduced in Node.js (version 8.4), and required `node` to be started with a flag `--expose-http2` up to version 8.7 (this module won't work without it). From Node.js 8.8, the `http2` module is available without any flag. The API has changed and not settled until 10.x, **and `fetch-h2` requires 10.x**.
**NOTE;** HTTP/2 support was introduced in Node.js (version 8.4), and required `node` to be started with a flag `--expose-http2` up to version 8.7 (this module won't work without it). From Node.js 8.8, the `http2` module is available without any flag. The API has changed and not settled until 10.x, **and `fetch-h2` requires 10.4+**.


## Releases
Expand Down
33 changes: 18 additions & 15 deletions certs/cert.pem
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
-----BEGIN CERTIFICATE-----
MIICpDCCAYwCCQCDxBRhc+faETANBgkqhkiG9w0BAQ0FADAUMRIwEAYDVQQDDAls
b2NhbGhvc3QwHhcNMTgwMTE2MTAwODExWhcNMTgwMjE1MTAwODExWjAUMRIwEAYD
VQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQD3
2vxYIFETHAQ8NhXWMYg3OTzqT0Q4dbsdBU6UOblPz7T96KyLl4MKsvOGfgtlqBW6
o3GEHDTUysLPwxG2oHpLK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CAQEAwd8VxBHL0Ovi0T1vbIhc52CIOdqP
lFnRtg/i8jNTrGCXjS2oERrHyvPHYwXSRis2zGbl+WQqZEHVDlVk/SY/z2DH1BTo
h+DIjd9fIlTXpaBTrU5QOKvJdIFjC7oSbxf1E8BtBrnuhwURHqPhEYKne8QdBGCT
HKRRprDa0GQQEJKVBDLmwMfVoLIh0k8ckjTOPx7126PfmsCTfae7psaplXLcJu9m
g/IcIPc8aRKvWLe8tM93p2rA0/1sO3Cj+ZCxWWaPoKmDa53TkFNLBaWMvO+sppXH
u57o5Wq2bF4fUpIvk6jNpqFvvGJhHiyMOpgzk1vtn+N/zraUTyeREkCHOQIDAQAB
MA0GCSqGSIb3DQEBCwUAA4IBAQCJQQA0YbqZEkQRWs0SWxF5NcZcXxyWrgagZ1Pb
LeuYpC3dczP2ugtUvzC5Gq1T6yOXyi2SI/wVu6AVOKx4WWtB61vGJUoVywcUR1ER
kshgQNcOMDPdVXEwZGCJZ162XhpWqGcYSbxZMPVvMmFB+qPkhmtimSSGOKUea29J
Zh6eyRIwgdrf7hfLqSB++Rr5kDGmT/jI7t/B9TySGfrO02+XDFoX19+ga5BV64pY
65fq9tkgpsbX1l6K+dGpTXSG+X/y4X4MJRjue3vOVcmMfXROO3G/MD99JSI+P+xU
jrgBhvpqcfC61nx62eNrXB/QpPUHdb2w+yXX0N2m5vnsX1nM
-----END CERTIFICATE-----
52 changes: 26 additions & 26 deletions certs/key.pem
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD32vxYIFETHAQ8
NhXWMYg3OTzqT0Q4dbsdBU6UOblPz7T96KyLl4MKsvOGfgtlqBW6o3GEHDTUysLP
wxG2oHpLKBT38QQtDYWMtPdPcHQcntiZD5AtZHDOEWeYCzQ4ef5evYishBHJV9xQ
jZTAg9faaK5cbfZJn7Csm3wqjXvh0CB0VQY6hCmrbZAff4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KBgQDvAZv5F3aHcM3acjfZ
FndMTsFLCXIXWUzjyvpaceHEOFSg00e9rR7c+nP8vK1CXfsIhukRgSvUDMkMpNXN
yptliRvWVQuy/0TZ8om8TiePCE86GZeRjSJTfYKo1z1mWj0pz+75p5kaSR4U669p
rkqFc+tcMoxX+Fisi5ku6Iy4+wKBgQDPp+5snzbv5VZsURCp9eNh4BypCNFWTkMH
kCWC7IEjkZ5jzhU9wfcEMLrTBdnOzT7RA/DfgJOcwylc2EKTN3NQuSg7ffFELM7P
tin0R+kO0JygDj9YhiIW1DfsKe2yJ59pdMDaXr214pI8WTtfZABpc0LnKnbDpJXP
+pzTuKFyWwKBgD8608KwXGE0jKEv+mpqMSF07Fono5FdxKO2/UiUPEAnDuyFOMOL
W1DmyWyhlcyrBFCbMGm7HJc60q2PpiiNY1MXVM/9K90s/1ARhDLXEkwazKr4Pkr5
ZY1k9P4qA0pisS+wnO5bUnvLwDOUrpFs1LY9lpSLoulbAEqVm+73AtOlAoGAMfR+
QRdUSgXr8obV8W071FHr0yZR5edR7MHapFJtBreDWRM8vOyqlhF7AEUKDtwFXpcK
HVp7KF0y2CkWawAN979zVEyJ/BKjdgimsyORh4TcCQ0kZBFwpflLsr6rdg5eJSp3
MpFUJitpbqcwx1PxXWzjDWWDyLERcUUi8TQbcr0CgYAXjId/k5Sm2EfeDsnGlR6L
HcPwJZ5iI+DrNg8sZn5u3EjhjcVT+mSe0CzMMqvKmwZ0LhmiB0ee0XiF0+iTsedd
Sru2OQgPkHgqxj71gBPk1NKozOb3pEDPqHMhuMjP/WBH2OPjB/bc84ayImlHGWaF
1lcTncGab2YneX4hdU15Qg==
-----END PRIVATE KEY-----
5 changes: 4 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Body, DataBody, JsonBody, StreamBody } from "./lib/body";
import { Context, ContextOptions, PushHandler } from "./lib/context";
import { Context, ContextOptions } from "./lib/context";
import { PushHandler } from "./lib/context-http2";
import { CookieJar } from "./lib/cookie-jar";
import {
AbortError,
DecodeFunction,
Decoder,
FetchInit,
HttpProtocols,
OnTrailers,
TimeoutError,
} from "./lib/core";
Expand Down Expand Up @@ -53,6 +55,7 @@ export {
onPush,

// Re-export
HttpProtocols,
Body,
JsonBody,
StreamBody,
Expand Down
Loading

0 comments on commit 69b56d0

Please sign in to comment.