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

get, post, put的区别 #120

Open
xszi opened this issue Apr 23, 2024 · 0 comments
Open

get, post, put的区别 #120

xszi opened this issue Apr 23, 2024 · 0 comments

Comments

@xszi
Copy link
Owner

xszi commented Apr 23, 2024

RESTful 是一种使用HTTP协议进行通信的Web服务。对于上传文件这个操作,PUT和POST都可以实现,但是官方建议使用PUT方法,因为PUT方法的语义本身就是“上传”或者“替换”一个资源。而POST方法则更加通用,可以用于上传文件,也可以用于创建资源、提交表单等多种操作。此外,PUT方法是幂等的,即多次执行同一PUT请求不会造成系统状态的变化;而POST方法不一定幂等,可能会影响系统状态。因此,在RESTful中,上传文件应该使用PUT方法。

PUT上传中参数通过请求头域传递;POST上传则作为消息体中的表单域传递。
PUT上传需在URL中指定对象名;POST上传提交的URL为桶域名,无需指定对象名。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant