Skip to content

Commit 152cb5e

Browse files
committed
docs: updated http2 documentation
following #1474 (5b86fd3)
1 parent dd6dd8c commit 152cb5e

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ The HTTP method defaults to __GET__, so if you wish, the following is valid:
9595

9696
## Using HTTP/2
9797

98-
To make a request using HTTP/2 protocol only (with no HTTP/1.x fallback), use the `.http2()` method. Currently we do not have auto-detection of HTTP/2-capable servers. This feature is experimental.
98+
To make a request using HTTP/2 protocol only (with no HTTP/1.x fallback), use the `.http2()` method.
9999

100100
```javascript
101101
const request = require('superagent');

docs/zh_CN/index.html

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ <h2 id="基本请求">基本请求</h2>
7373

7474
});
7575
</code></pre>
76+
<h2 id="使用-http-2">使用 HTTP/2</h2>
77+
<p>要使用 HTTP/2 协议(没有 HTTP/1.x 后备),请使用 <code>.http2()</code> 方法。</p>
78+
<pre><code class="language-javascript"> const request = require(&#39;superagent&#39;);
79+
const res = await request
80+
.get(&#39;https://example.com/h2&#39;)
81+
.http2();
82+
</code></pre>
7683
<h2 id="设置请求头字段">设置请求头字段</h2>
7784
<p>设置请求头字段很简单,调用 <code>.set()</code> 时传入字段名称和值:</p>
7885
<pre><code> request

docs/zh_CN/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ HTTP 方法默认为 __GET__,因此如果您愿意,以下代码是有效的
7777

7878
});
7979

80+
## 使用 HTTP/2
81+
82+
要使用 HTTP/2 协议(没有 HTTP/1.x 后备),请使用 `.http2()` 方法。
83+
84+
const request = require('superagent');
85+
const res = await request
86+
.get('https://example.com/h2')
87+
.http2();
88+
8089
## 设置请求头字段
8190

8291
设置请求头字段很简单,调用 `.set()` 时传入字段名称和值:

index.html

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ <h2 id="request-basics">Request basics</h2>
7373

7474
});
7575
</code></pre>
76+
<h2 id="using-http/2">Using HTTP/2</h2>
77+
<p>To make a request using HTTP/2 protocol only (with no HTTP/1.x fallback), use the <code>.http2()</code> method.</p>
78+
<pre><code class="language-javascript"> const request = require(&#39;superagent&#39;);
79+
const res = await request
80+
.get(&#39;https://example.com/h2&#39;)
81+
.http2();
82+
</code></pre>
7683
<h2 id="setting-header-fields">Setting header fields</h2>
7784
<p>Setting header fields is simple, invoke <code>.set()</code> with a field name and value:</p>
7885
<pre><code class="language-javascript"> request

0 commit comments

Comments
 (0)