I am trying to write a small C ++ web server that handles GET, POST, HEAD requests. My problem is that I don’t know how to parse headers, message body, etc. He listens to the socket, I can even write stuff in the browser just fine, but I'm wondering how can I do this in C ++.
Afaik's standard GET / POST request should look something like this:
GET /index HTTP/1.1
Host: 192.168.0.199:80
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
this is the message body
All lines end with '\ r \ n'.
Should I just split the request into "\ n" and trim them (and if so, how)? Also how to process files in post data?
, , - , key = > value, , (, PHP, ) (, ) , '/'.
!