QNetworkAccessManager: put request uncomplete on localhost
-
Hi
For a REST client/server solution I try to usethe QNetworkAccessManager::put() method for HTTP PUT requests in the client app. The server receives only the HTTP header but no content data (ca. 2500 bytes) if both runs on the same machine (localhost). Content length is correct in the received HTTP header. The server app uses the QTcpServer class. It receives the header twice (after time out for content) from the client but no content data. I got no error value and GET requests works fine.
With two different machines the put request works like expected. With a Java REST test application put request works fine on localhost.
This occurs on Windows and Linux.Any ideas?
Thanks
Bernd -
How are you invoking QNetworkAccessManager::put exactly? Can you -attach- pastebin/upload somewhere a complete pcap log?
-
The code:
@QNetworkRequest request;
request.setUrl(url);
if(!szUserAgent.isEmpty())
{
request.setRawHeader("User-Agent", szUserAgent.toAscii());
}
if(!szAcceptEncoding.isEmpty())
{
request.setRawHeader("Accept-Encoding", szAcceptEncoding.toAscii());
}
if(!szContentType.isEmpty())
{
request.setHeader(request.ContentTypeHeader, szContentType);m_pReply = m_manager->put(request, baContent);
if(m_pReply != 0L)
{
connect(m_pReply, SIGNAL(error ( QNetworkReply::NetworkError)), this, SLOT( PutRequestError(QNetworkReply::NetworkError)));
connect(m_pReply, SIGNAL( uploadProgress ( qint64 , qint64)), this, SLOT( PutRequestUploadProgress ( qint64 , qint64)));
QNetworkReply::NetworkError error = m_pReply->error();
if(error == QNetworkReply::NoError)
{
...
}@The baContent is a QByteArray with XML content.
Is it possible to log localhost network traffic? I thought it is only possible with real network traffic. But I have only exerience with Wireshark on Windows. I will try to get a log.
-
It's possible to capture local traffic.
BTW, what's at line 23? Why are you checking for errors even before than returning to the event loop?
-
There is nothing only a debug messages and set a return value for the method. I added this after I saw that it doesn't work. I thought that maybe I get an error right after the call that helps me.
Could the live time of the content QByteArray be a problem? -
No, the byte array will be copied (using implicit sharing) to the request object, so doubt that is it.
-
I logged the request and it seems to be ok. Both header and content are present in one packet. I will take a closer look to the server code.
-
I solved the problem. It was a problem in the server code that under some circumstances the put content was not received or better say flushed.
Thanks for your help!
Bernd