[Interest] Question about usage QNetworkRequest with QNetworkRequest::AuthenticationReuseAttribute set to QNetworkRequest::Manual

Alex Malyushytskyy alexmalvtk at gmail.com
Sat Aug 11 01:24:11 CEST 2012


I am starting url request as

void ubFileManager::startRequest( QUrl _url )
{
	qDebug() << "url=" << _url;

	QNetworkRequest request (url);
	request.setAttribute ( QNetworkRequest::AuthenticationReuseAttribute,
QVariant( QNetworkRequest::Manual ) );
 // where qnam is instance ofQNetworkAccessManager
	reply = qnam.get( request );
    connect(reply, SIGNAL(finished()),   this, SLOT(httpFinished()));

}

In  httpFinished() reply->error() is set to "Host requires
authentication" ( I left only my code which executed  below)

void ubFileManager::httpFinished()
{
.........

    if (reply->error()) {
        QMessageBox::information( qobject_cast<QWidget*>(parent()), tr("HTTP"),
                                 tr("Download failed: %1.")
                                 .arg(reply->errorString()));

	reply->deleteLater();
	reply = 0;

	emit loadingError( threadId );
        return;

    }
..........

            return;
 }

Even though I have not done authentication, so far so good.
I've sent request, got an expected error.

Problem is that next thing what happens is unhandled exception in
QNetworkd4.dll.
Checking Call Stack in a few cases gives me an impression that this
might be multithreaded code,
cause point of the failure and order of calls seems changing depending
on the break points set.
But failure always occur somewhere in the  QHttpNetworkConnectionChannel.cpp .

In one of the cases  I get exception thrown in
bool QHttpNetworkConnectionChannel::sendRequest()

.................

    // read loop for the response
    while (socket->bytesAvailable()) {
// exception is thrown below, cause reply is null
        QHttpNetworkReplyPrivate::ReplyState state = reply->d_func()->state;

        switch (state) {
        case QHttpNetworkReplyPrivate::NothingDoneState: {


Call stack is below:


>	QtNetworkd4.dll!QHttpNetworkConnectionChannel::_q_receiveReply()  Line 362 + 0xb bytes	C++

 	QtNetworkd4.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData>
>::data()  Line 135 + 0x3 bytes	C++
 	QtNetworkd4.dll!qGetPtrHelper<QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData>
> >(const QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData>
> & p)  Line 2338 + 0xb bytes	C++
 	QtNetworkd4.dll!QHttpNetworkReply::d_func()  Line 161 + 0x13 bytes	C++
>	QtNetworkd4.dll!QHttpNetworkConnectionChannel::_q_receiveReply()  Line 362 + 0xb bytes	C++
 	QtNetworkd4.dll!QHttpNetworkConnectionChannel::_q_readyRead()  Line 885	C++
 	QtNetworkd4.dll!QHttpNetworkConnectionChannel::qt_metacall(QMetaObject::Call
_c, int _id, void * * _a)  Line 87 + 0x8 bytes	C++
 	QtCored4.dll!QMetaObject::metacall(QObject * object,
QMetaObject::Call cl, int idx, void * * argv)  Line 238	C++
 	QtCored4.dll!QMetaObject::activate(QObject * sender, const
QMetaObject * m, int local_signal_index, void * * argv)  Line 3278 +
0x27 bytes	C++
 	QtCored4.dll!QIODevice::readyRead()  Line 91 + 0x12 bytes	C++
 	QtNetworkd4.dll!QAbstractSocketPrivate::canReadNotification()  Line 640	C++
 	QtNetworkd4.dll!QAbstractSocketPrivate::readNotification()  Line 77
+ 0x15 bytes	C++
 	QtNetworkd4.dll!QAbstractSocketEngine::readNotification()  Line 155	C++
 	QtNetworkd4.dll!QReadNotifier::event(QEvent * e)  Line 1104	C++
 	QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver,
QEvent * e)  Line 4462 + 0x11 bytes	C++
 	QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e)
Line 3862 + 0x10 bytes	C++
 	QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver,
QEvent * event)  Line 731 + 0x15 bytes	C++
 	QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent
* event)  Line 215 + 0x39 bytes	C++
 	QtCored4.dll!qt_internal_proc(HWND__ * hwnd, unsigned int message,
unsigned int wp, long lp)  Line 485 + 0xf bytes	C++
 	user32.dll!76a062fa() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for
user32.dll]
 	user32.dll!76a06d3a() 	
 	user32.dll!76a06ce9() 	
 	user32.dll!76a077c4() 	
 	user32.dll!76a0788a() 	
 	QtCored4.dll!QEventDispatcherWin32::processEvents(QFlags<enum
QEventLoop::ProcessEventsFlag> flags)  Line 813	C++
 	QtGuid4.dll!QGuiEventDispatcherWin32::processEvents(QFlags<enum
QEventLoop::ProcessEventsFlag> flags)  Line 1170 + 0x15 bytes	C++
 	QtCored4.dll!QEventLoop::processEvents(QFlags<enum
QEventLoop::ProcessEventsFlag> flags)  Line 150	C++
 	QtCored4.dll!QEventLoop::exec(QFlags<enum
QEventLoop::ProcessEventsFlag> flags)  Line 201 + 0x2d bytes	C++
 	QtCored4.dll!QCoreApplication::exec()  Line 1008 + 0x15 bytes	C++
 	QtGuid4.dll!QApplication::exec()  Line 3737	C++
 	UrbanBlast.exe!main(int argc, char * * argv)  Line 120 + 0x6 bytes	C++
 	UrbanBlast.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ *
prevInstance, char * __formal, int cmdShow)  Line 131 + 0x12 bytes	C++
 	UrbanBlast.exe!__tmainCRTStartup()  Line 547 + 0x2c bytes	C
 	UrbanBlast.exe!WinMainCRTStartup()  Line 371	C
 	kernel32.dll!752a339a() 	
 	ntdll.dll!775a9ef2() 	
 	ntdll.dll!775a9ec5() 	


Do I miss something or this should be reported as a bug?

Regards,
    Alex



More information about the Interest mailing list