哪里可以找到HTTP方法示例? [英] Where to find HTTP methods examples?

查看:131
本文介绍了哪里可以找到HTTP方法示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP定义了八种方法(有时也称为动词)

你能帮我找一下每个例子,这样我可以更好地测试和理解它们吗?

Can you help me find examples for each one so I can test and understand them better?

推荐答案

首先,您应该查看 HTTP 1.1规范,尤其是部分方法定义

First you should take a look into the HTTP 1.1 specification, especially the section method definitions.


  • OPTIONS 获取有关服务器如何与之通信的信息。

  • OPTIONS Get information about how the server allows to communicate with.

请求:

OPTIONS * HTTP/1.1
Host: example.com

回复:

HTTP/1.1 200 OK
Date: …
Allow: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE
Content-Length: 0


  • 获取检索资源。

    请求:

    GET /foo/bar HTTP/1.1
    Host: example.com
    

    回复:

    HTTP/1.1 200 OK
    Date: …
    Content-Type: text/html;charset=utf-8
    Content-Length: 12345
     
    <!DOCTYPE …
    


  • HEAD GET 类似,但只返回HTTP标头。

  • HEAD Like GET, but returns just the HTTP header.

    请求:

    HEAD /foo/bar HTTP/1.1
    Host: example.com
    

    回复:

    HTTP/1.1 200 OK
    Date: …
    Content-Type: text/html;charset=utf-8
    Content-Length: 12345
    


  • POST 创建新资源。

    请求:

    POST /foo/bar HTTP/1.1
    Host: example.com
    Content-Type: application/x-www-form-urlencoded
     
    action=addentry&subject=Hello,%20World
    

    回复:

    HTTP/1.1 201 Created
    Date: …
    Content-Length: 0
    Location: http://example.com/foo/bar        
    


  • PUT 将数据发送到服务器。

  • PUT Send data to the server.

    删除删除现有资源。

    TRACE 返回客户端发送的请求标头。

    TRACE Return the request headers sent by the client.

    请求:

    TRACE /foo/bar HTTP/1.1
    Host: example.com
    

    回复:

    HTTP/1.1 200 OK
    Date: …
    Content-Length: 17
     
    Host: example.com
    


  • 我不确切知道这些例子是否正确。随意纠正它们。

    I don’t know exactly if these examples are correct. Feel free to correct them.

    这篇关于哪里可以找到HTTP方法示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆