Skip to content

Commit

Permalink
Merge pull request #1739 from lamweili/patch-1
Browse files Browse the repository at this point in the history
docs: updated http2 documentation
  • Loading branch information
titanism committed Sep 17, 2022
2 parents fad7b59 + 152cb5e commit 29fd1f9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ The HTTP method defaults to __GET__, so if you wish, the following is valid:

## Using HTTP/2

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.
To make a request using HTTP/2 protocol only (with no HTTP/1.x fallback), use the `.http2()` method.

```javascript
const request = require('superagent');
const res = await request
.get('https://example.com/h2')
.http2();
```

## Setting header fields

Expand Down
7 changes: 7 additions & 0 deletions docs/zh_CN/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ <h2 id="基本请求">基本请求</h2>

});
</code></pre>
<h2 id="使用-http-2">使用 HTTP/2</h2>
<p>要使用 HTTP/2 协议(没有 HTTP/1.x 后备),请使用 <code>.http2()</code> 方法。</p>
<pre><code class="language-javascript"> const request = require(&#39;superagent&#39;);
const res = await request
.get(&#39;https://example.com/h2&#39;)
.http2();
</code></pre>
<h2 id="设置请求头字段">设置请求头字段</h2>
<p>设置请求头字段很简单,调用 <code>.set()</code> 时传入字段名称和值:</p>
<pre><code> request
Expand Down
9 changes: 9 additions & 0 deletions docs/zh_CN/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ HTTP 方法默认为 __GET__,因此如果您愿意,以下代码是有效的

});

## 使用 HTTP/2

要使用 HTTP/2 协议(没有 HTTP/1.x 后备),请使用 `.http2()` 方法。

const request = require('superagent');
const res = await request
.get('https://example.com/h2')
.http2();

## 设置请求头字段

设置请求头字段很简单,调用 `.set()` 时传入字段名称和值:
Expand Down
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ <h2 id="request-basics">Request basics</h2>

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

0 comments on commit 29fd1f9

Please sign in to comment.