get 和 post的使用.
Two commonly used methods for a request-response between a client and server are: GET and POST.
- GET - Requests data from a specified resource
- POST - Submits data to be processed to a specified resource
The GET Method
Note that query strings (name/value pairs) is sent in the URL of a GET request:
test/demo_form.asp?name1=value1&name2=value2
Some other notes on GET requests: GET requests can be cached
GET requests remain in the browser history
GET requests can be bookmarked
GET requests should never be used when dealing with sensitive data
GET requests have length restrictions
GET requests should be used only to retrieve data
The POST Method
Note that query strings (name/value pairs) is sent in the HTTP message body of a POST request:
POST /test/demo_form.asp HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2
Some other notes on POST requests: POST requests are never cached
POST requests do not remain in the browser history
POST requests cannot be bookmarked
POST requests have no restrictions on data l are GET vs. POST
The following table compares the two HTTP methods: GET and POST.
GET | POST | |
---|---|---|
BACK button/Reload | Harmless | Data will be re-submitted (the browser should alert the user that the data are about to be re-submitted) |
Bookmarked | Can be bookmarked | Cannot be bookmarked |
Cached | Can be cached | Not cached |
Encoding type | application/x-www-form-urlencoded | application/x-www-form-urlencoded or multipart/form-data. Use multipart encoding for binary data |
History | Parameters remain in browser history | Parameters are not saved in browser history |
Restrictions on data length | Yes, when sending data, the GET method adds the data to the URL; and the length of a URL is limited (maximum URL length is 2048 characters) | No restrictions |
Restrictions on data type | Only ASCII characters allowed | No restrictions. Binary data is also allowed |
Security | GET is less secure compared to POST because data sent is part of the URL
Never use GET when sending passwords or other sensitive information! |
POST is a little safer than GET because the parameters are not stored in browser history or in web server logs |
Visibility | Data is visible to everyone in the URL | Data is not displayed in the URL |
Other HTTP Request Methods
The following table lists some other HTTP request methods:
Method | Description |
---|---|
HEAD | Same as GET but returns only HTTP headers and no document body |
PUT | Uploads a representation of the specified URI |
DELETE | Deletes the specified resource |
OPTIONS | Returns the HTTP methods that the server supports |
CONNECT | Converts the request connection to a transparent TCP/IP tunnel |
Href:http://www.w3schools.com/tags/ref_httpmethods.asp
随机推荐
- 【UVA11019】Matrix Matcher
Description Given an N × M matrix, your task is to find the number of occurences of an X × Y pattern ...
- 如何用python语句获得Python的安装目录
官方文档上有写的,sys.executable是当前Python解释器(或者其他Python实现)的路径去掉后面一个路径分隔符(Windows下是'\')后的部分即可 >>>impo ...
- mysql之索引方面的知识点总结
索引的类型: 普通索引:这是最基本的索引类型,没唯一性之类的限制. 唯一性索引:和普通索引基本相同,但所有的索引列只能出现一次,保持唯一性. 主键:主键是一种唯一索引,但必须指定为"PRIM ...
- Mongo的导出工具mongoexport介绍
需求介绍:将mongodb中的数据以文件的方式导出:json或cvs格式 mongo 提供了mongoexport的工具,可以实现将库中的数据以json或cvs的格式输出到文件中.mongoexpor ...
- 坑爹的Android Ble 问题记录日志
开发Ble(公司项目,防丢器)已经有一段时间,由于是第一次接触Ble而网上资料又不多,且android平台自身的差异性,遇到了很多问题.为了将来方便查阅,在此做下记录.1.中兴手机,蓝牙手动断开后,无 ...
- ASP.NET MVC 后台接收集合参数和 jquery ajax 传值
MVC 接收参数数组(集合) 示例样本: public class Person { public string FirstName { get; set; } publi ...
- Linux Kernel ‘perf’ Utility 本地提权漏洞
漏洞名称: Linux Kernel ‘perf’ Utility 本地提权漏洞 CNNVD编号: CNNVD-201309-050 发布时间: 2013-09-09 更新时间: 2013-09-09 ...
- jQuery zxxbox弹出框插件(v3.0)
插件地址: http://www.zhangxinxu.com/study/201009/jquery-zxxbox-v3-demo.html
- poj-1782 Run Length Encoding
http://poj.org/problem?id=1782 Run Length Encoding Time Limit: 1000MS Memory Limit: 30000K Total S ...
- excel小技巧-用于测试用例的编号栏:“获取当前单元格的上一格的值+1”=INDIRECT(ADDRESS(ROW()-1,COLUMN()))+1
编写用例的时候使用,经常修改用例的时候会需要增加.删除.修改条目,如果用下拉更新数值的方式会很麻烦. 1.使用ctrl下拉,增删移动用例的时候,需要每次都去拉,万一列表比较长,会很麻烦 2.使用ROW ...