Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: updated http2 documentation #1739

Merged
merged 2 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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