POST / HTTP/1.1 <--------------start line Host: localhost : 8000 User-Agent: Mozila/5.0 Accept : text/html, application/xhtml + xml,... Accept-Language: en-US, en; q=0.5 Aceept-Encoding: gzip, deflate Connection: keep-alive Upgrade-Insecure-Request: 1 Content-Type: multipart/from-data; boundary=1265684 Content-Length: 345 <--------------empty line-123456789 <----------------body(more data)//Строки между start line и empty line это http headers
C++ (Qt)QString http_start_line = "POST / HTTP/1.1";QFile xml_file;...QByteArray ba_file = xml_file.readAll();... QByteArray buffer;buffer.appent(http_start_line);buffer.append(ba_file); socket.write(buffer.data(), buffer.size());
C++ (Qt)const unsigned int Delimetr = 0xABCCCCBA; struct message_header{ uint32_t delimetr = ::Delimetr; uint32_t size;}; void Service::prepareMessageAndSend(){ //HTTPQString http_string = "GET /something operations server will do / HTTP/1.1";int http_str_sz = http_string.size(); //XMLQFile xmlfile;...QByteArray ba_xml = xmlfile.readAll();int xml_file_sz = ba.size(); //TCP MY_MESSAGE_HEADERmessage_header msghdr;msghdr.size = sizeof(message_header) + http_str_sz + xml_file_sz; //INPUT BUFFER QByteArray buffer;buffer.append(reinterpret_cast<char *>(&msghdr), sizeof(message_header));buffer.append(http_string);buffer.append(ba_xml); //SENDsocket.write(buffer.data(), buffer.size()); }