V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
httpbin - 协议调试工具
httpstatuses - 协议状态码查询
httpie - cURL-like tool for humans
Fiddler
FaiChou
V2EX  ›  HTTP

HTTP 请求方法有 VIEW 吗?

  •  
  •   FaiChou · 2020-02-27 14:32:52 +08:00 · 2346 次点击
    这是一个创建于 1518 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    postman

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

    charles

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

    有没有人见过 /用过?

    11 条回复    2020-03-04 16:44:12 +08:00
    loading
        1
    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
        2
    FaiChou  
    OP
       2020-02-27 14:37:50 +08:00
    @loading #1 嗯,我也搜遍全网,都没有发现任何关于 VIEW 的解释。

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

    http1.1 2.0 新加的都没有这个方法。
    fancy111
        3
    fancy111  
       2020-02-27 14:39:10 +08:00
    有吗?没用过。 就算有也不稀奇啊,你可以自定义协议的,名字随便你取
    FaiChou
        4
    FaiChou  
    OP
       2020-02-27 15:14:43 +08:00
    @fancy111 #3 在某 app 上见到过,并且在 postman 中能看到有这个默认方法,所以以为是个常用请求方法。但是搜索却无果。
    yhl10000
        5
    yhl10000  
       2020-02-27 15:42:28 +08:00
    postman 右侧 save 按钮下面有个 Code, 点击后,可以看到各种请求,比如 curl 风格的。拷贝出来,在其他地方请求,然后捕捉。
    FaiChou
        6
    FaiChou  
    OP
       2020-02-27 16:10:46 +08:00
    @yhl10000 #5 谢谢,在 Charles 上也能右键复制为 cURL,和 postman 一样复制出来的 cURL 都是 VIEW 的请求方法。
    FaiChou
        7
    FaiChou  
    OP
       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
        8
    yhl10000  
       2020-03-02 11:34:36 +08:00
    @FaiChou 抱歉,我想我之前误解你的问题了。
    如 fancy111 说的,我 google 了下也没找到。在 postman 的文档内也没找到说明。
    难道是 postman 自己弄了个 method ?
    FaiChou
        9
    FaiChou  
    OP
       2020-03-02 15:42:25 +08:00
    @yhl10000 #8 postman 自己新建请求方法。。应该不可能。 因为我在另外一个 app 抓包也捕获到它使用 VIEW 请求方法了。
    yhl10000
        10
    yhl10000  
       2020-03-04 15:48:03 +08:00
    @FaiChou 自定义 method,就是 http headers 里面的 method 的值是自定义的。换句话说,是调用者和被调用者知道就行。常规的服务器或者浏览器是不知道的。
    FaiChou
        11
    FaiChou  
    OP
       2020-03-04 16:44:12 +08:00
    @yhl10000 #10 嗯,自定义请求方法我是知道的,如果只有那个 app 里使用了 VIEW 这个方法,我大概会以为是自定义的。但在 postman 中也发现相同的请求方法,我觉得不是巧合。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3137 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 14:59 · PVG 22:59 · LAX 07:59 · JFK 10:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.