HTTP 请求方法有 VIEW 吗?

2020-02-27 14:32:52 +08:00
 FaiChou

在 Postman 中能够看到有一个 VIEW 的请求方法:

并且在某 app 抓包中发现有使用的例子:

但是在网上找不到任何关于 VIEW 相关的内容,w3c/wikipedia/rfc 都没找到.

有没有人见过 /用过?

2357 次点击
所在节点    HTTP
11 条回复
loading
2020-02-27 14:34:43 +08:00
没有吧

developer.mozilla.org/en-US/docs/Web/HTTP/Methods

```

GET
The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
HEAD
The HEAD method asks for a response identical to that of a GET request, but without the response body.
POST
The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
PUT

The PUT method replaces all current representations of the target resource with the request payload.
DELETE
The DELETE method deletes the specified resource.
CONNECT

The CONNECT method establishes a tunnel to the server identified by the target resource.
OPTIONS
The OPTIONS method is used to describe the communication options for the target resource.
TRACE

The TRACE method performs a message loop-back test along the path to the target resource.
PATCH
The PATCH method is used to apply partial modifications to a resource.
```
FaiChou
2020-02-27 14:37:50 +08:00
@loading #1 嗯,我也搜遍全网,都没有发现任何关于 VIEW 的解释。

但 postman 和 charles 抓包看到的这个情况,又难以解释。。

http1.1 2.0 新加的都没有这个方法。
fancy111
2020-02-27 14:39:10 +08:00
有吗?没用过。 就算有也不稀奇啊,你可以自定义协议的,名字随便你取
FaiChou
2020-02-27 15:14:43 +08:00
@fancy111 #3 在某 app 上见到过,并且在 postman 中能看到有这个默认方法,所以以为是个常用请求方法。但是搜索却无果。
yhl10000
2020-02-27 15:42:28 +08:00
postman 右侧 save 按钮下面有个 Code, 点击后,可以看到各种请求,比如 curl 风格的。拷贝出来,在其他地方请求,然后捕捉。
FaiChou
2020-02-27 16:10:46 +08:00
@yhl10000 #5 谢谢,在 Charles 上也能右键复制为 cURL,和 postman 一样复制出来的 cURL 都是 VIEW 的请求方法。
FaiChou
2020-02-27 16:14:42 +08:00
@yhl10000 #5 复制为 fetch 的:

```
var requestOptions = {
method: 'VIEW',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://api.xxxxx.com", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
```

复制为 cURL 的:

```
curl --location --request VIEW 'https://api.xxxx' \
--header 'Content-Type: application/json' \
--header '...' \
--data-raw '{xx:1}'
```
yhl10000
2020-03-02 11:34:36 +08:00
@FaiChou 抱歉,我想我之前误解你的问题了。
如 fancy111 说的,我 google 了下也没找到。在 postman 的文档内也没找到说明。
难道是 postman 自己弄了个 method ?
FaiChou
2020-03-02 15:42:25 +08:00
@yhl10000 #8 postman 自己新建请求方法。。应该不可能。 因为我在另外一个 app 抓包也捕获到它使用 VIEW 请求方法了。
yhl10000
2020-03-04 15:48:03 +08:00
@FaiChou 自定义 method,就是 http headers 里面的 method 的值是自定义的。换句话说,是调用者和被调用者知道就行。常规的服务器或者浏览器是不知道的。
FaiChou
2020-03-04 16:44:12 +08:00
@yhl10000 #10 嗯,自定义请求方法我是知道的,如果只有那个 app 里使用了 VIEW 这个方法,我大概会以为是自定义的。但在 postman 中也发现相同的请求方法,我觉得不是巧合。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/648043

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX