11.12
run server
(cd chapter11/code; make && ./tiny.12 5000)
visit http://localhost:5000/post-home.html
and submit
POST method pass param by message-body behind Headers part.
When we input 9 and 10 and submit, socket pass content
POST /cgi-bin/post-adder HTTP/1.1
Host: localhost:5000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 16
Referer: http://localhost:5000/post-home.html
Cookie: _ga=GA1.1.1286836072.1494744693
Connection: keep-alive
Upgrade-Insecure-Requests: 1
(CRLF here, message-body below)
first=9&second=10
Content-Length marks the length of message-body.
use readnb
to fetch post param.
!INCLUDE "./code/tiny.12.c.diff"
post-adder code
!INCLUDE "./code/cgi-bin/post-adder.c"
当前内容版权归 DreamAndDead 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 DreamAndDead .