content type 介绍
生活随笔
收集整理的這篇文章主要介紹了
content type 介绍
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本篇介紹以html表單提交數據為例,講述content-type頭
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>測試表單提交Post</title> </head> <body> <form action="post.php" method="post"> <input type="text" name='username'> <input type="text" name='password'> <input type="submit"> </form> </body> </html>這種最常見的表單,它的請求頭為:
POST /test/httpPost/post.php HTTP/1.1 Host: localhost Connection: keep-alive Content-Length: 27 Cache-Control: max-age=0 Origin: http://localhost Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 Content-Type: application/x-www-form-urlencoded Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 Referer: http://localhost/test/httpPost/index.html Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.8 Cookie: pgv_pvi=8193968128
請求體:
username=zzzz&password=tttt
這里需要注意的是,請求體里的值是經過url encode的
另一種比較復雜的http請求是這樣的
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>測試表單提交Post</title> </head> <body> <form action="post.php" method="post" enctype="multipart/form-data"> <input type="text" name='username'> <input type="text" name='password'> <input type="file" name='picture'> <input type="submit"> </form> </body> </html>申明了content-type的值為multipart/form-data
這種http post請求頭為: POST /test/httpPost/post.php HTTP/1.1Host: localhost Connection: keep-alive Origin: http://localhost User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 Content-Type: multipart/form-data; boundary=—-WebKitFormBoundaryo8HMWnZkFmHAvcTX聲明為這種類型時,后面的boundary參數指定每個參數之間的分隔符 請求體為: ——WebKitFormBoundaryo8HMWnZkFmHAvcTX Content-Disposition: form-data; name=”username”aaa ——WebKitFormBoundaryo8HMWnZkFmHAvcTX Content-Disposition: form-data; name=”password”bbb ——WebKitFormBoundaryo8HMWnZkFmHAvcTX Content-Disposition: form-data; name=”picture”; filename=”1488794518kqnZP.jpg” Content-Type: image/jpeg——WebKitFormBoundaryo8HMWnZkFmHAvcTX–注意這時候的值沒有經過url encode
轉載于:https://www.cnblogs.com/amyleell/p/9119796.html
總結
以上是生活随笔為你收集整理的content type 介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 织梦多个栏目arclist调用副栏目不显
- 下一篇: 作业二:购物车程序