我需要向我的虚拟机发送几个发布请求 . 我从pcap文件中获取数据包的示例,然后修改它们以插入我的数据(我这样做是因为数据格式相当奇怪) . 首先,我向我的服务器发送一个空的post请求(变量none),一切正常,服务器响应我 . 但后来我需要发送另一个帖子请求(变量challenge_responce),但是当我第一次这样做时,服务器不响应我 .

none = "POST /jsproxy HTTP/1.1
Host: 192.168.37.2
Connection: keep-alive
Content-Length: 0
Pragma: no-cache
Cache-Control: no-cache
Origin: file://
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: username=admin"
challenge_responce = "POST /jsproxy HTTP/1.1
Host: 192.168.37.2
Connection: keep-alive
Content-Length: 117
Pragma: no-cache
Cache-Control: no-cache
Origin: file://
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: username=admin

ДЂДЂДЂДЂДЂДЂДЂ/Rñ±•Â$0[^96“ù¦ĀĀ!@#$%^&*()_+:3|~ĀĀĀĀĀĀĀĀ§Ç1&TВЌВЌpMГЇm)[4}(В¤<HГѓ%Гў(Г„Гadmin"

这是我的代码:

packet = pcap_next(handle, &header);
Arrcpy(none, ParsePacket(packet, length), 1000);

packet = pcap_next(handle, &header);
Arrcpy(challenge, ParsePacket(packet, length), 1000);

packet = pcap_next(handle, &header);
Arrcpy(challenge_responce, ParsePacket(packet, length), 1000);

boost::asio::ip::tcp::iostream stream("192.168.37.2", "http");

stream << none;

std::string temp;
std::string chPacket;
auto t = stream.rdbuf();
while (std::getline(stream, temp))
    chPacket += temp;

auto code = GetChallenge(chPacket);

std::string modChallengeResponce = ModifyChallengeResponce(challenge_responce, length, code, "qazwsx12");

stream << modChallengeResponce;
std::string resq;

while (std::getline(stream, temp))
    resq += temp;

std::cout << stream.rdbuf();

我该如何解决?可能是我不用tcp :: iostream ??