Ashley
16th April 2015, 17:06
I'm trying to implement http pipelining in Qt but I can't seem to get it working and there are no examples I can find on the internet. Currently my code looks like:
slotDataReceived(QNetworkReply){
// ...process reply...
// Send more GET requests as needed
while (responsesPending < maxPipelinedGets) //maxPipelinedGets is set to 6
{
QUrl* pServerUrl = new QUrl();
pServerUrl->setHost(mAddress);
pServerUrl->setPort(mPort);
pServerUrl->setScheme("http");
QNetworkRequest networkRequest(*pServerUrl);
networkRequest.setAttribute(QNetworkRequest::HttpP ipeliningAllowedAttribute, true);
networkRequest.setRawHeader("Host",mAddress.toLocal8Bit() + ":" + QString::number(mPort).toLocal8Bit());
networkRequest.setRawHeader("Pragma", "no-cache");
if(messageID != "")
networkRequest.setRawHeader("MsgID", messageID.toLocal8Bit());
cout << "Sending HTTP GET request";
networkManager->get(QNetworkRequest(*pServerUrl));
++responsesPending;
delete pServerUrl;
}
}
I still get responses from the server - but every time i get a response, 8 requests are sent, then 7 immediately come back with network reply errors, whilst one sits there waiting for another response, which suggests to me there is no http pipelining functionality present.
If anyone could help direct me to a working solution that would be greatly appreciated! :)
slotDataReceived(QNetworkReply){
// ...process reply...
// Send more GET requests as needed
while (responsesPending < maxPipelinedGets) //maxPipelinedGets is set to 6
{
QUrl* pServerUrl = new QUrl();
pServerUrl->setHost(mAddress);
pServerUrl->setPort(mPort);
pServerUrl->setScheme("http");
QNetworkRequest networkRequest(*pServerUrl);
networkRequest.setAttribute(QNetworkRequest::HttpP ipeliningAllowedAttribute, true);
networkRequest.setRawHeader("Host",mAddress.toLocal8Bit() + ":" + QString::number(mPort).toLocal8Bit());
networkRequest.setRawHeader("Pragma", "no-cache");
if(messageID != "")
networkRequest.setRawHeader("MsgID", messageID.toLocal8Bit());
cout << "Sending HTTP GET request";
networkManager->get(QNetworkRequest(*pServerUrl));
++responsesPending;
delete pServerUrl;
}
}
I still get responses from the server - but every time i get a response, 8 requests are sent, then 7 immediately come back with network reply errors, whilst one sits there waiting for another response, which suggests to me there is no http pipelining functionality present.
If anyone could help direct me to a working solution that would be greatly appreciated! :)