HTTP相關知識積累 原

HTTP相關知識積累

來源:https://sookocheff.com/post/api/when-to-use-http-put-and-http-post/

文件上傳時候的PUT和POST

The PUT method not as widely used as the POST method is the more efficient way of uploading files to a server.

This is because in a POST upload the files need to be combined together into a multipart message and this message has to be decoded at the server.

In contrast,the PUT method allows you to simply write the contents of the file to the socket connection that is established with the server.

When using the POST method,all the files are combined together into a single multipart/form-data type object. This MIME message when transferred to the server,has to be decoded by the server side handler. The decoding process may consume significant amounts of memory and CPU cycles for very large files.

The disadvantage with the PUT method is that if you are on a shared hosting enviorenment it may not be available to you.

The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process,a gateway to some other protocol, or a separate entity that accepts annotations.

In contrast,the URI in a PUT request identifies the entity enclosed with the reques


ASCII (American Standard Code For Infomation Interchange). 一共128個,其中***95個可見(32-126)***其餘33個不可見.


HTTP協議是以ASCII碼傳輸,建立在TCP/IP協議之上的應用層規範. 你會Base64一把是因爲你Base64以後的那些字符肯定在ASCII碼範圍內.


Q:content-type:application/json 和 application/x-www-form-urlencoded有什麼不一樣? A:Content-Type是***application/json***用來告訴服務端消息主體是序列化後的***JSON字符串***. 就是你提交那些東西可以有結構.好比{"a":"b","c":[1,2,3]}.

Content-Type是***application/x-www-form-urlencoded***, 這意味着消息內容會經過URL編碼,就像在GET請求時URL裏的QueryString那樣.


待學習博客: https://imququ.com/post/http-public-key-pinning.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章