Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qtbase-staging
* 'master' of git://scm.dev.nokia.troll.no/qt/qtbase-staging: add test case for ipv6 url parsingbb10
commit
49cf3e27e2
|
|
@ -219,6 +219,8 @@ private Q_SLOTS:
|
|||
void putGetDeleteGetFromHttp();
|
||||
void sendCustomRequestToHttp_data();
|
||||
void sendCustomRequestToHttp();
|
||||
void connectToIPv6Address_data();
|
||||
void connectToIPv6Address();
|
||||
|
||||
void ioGetFromData_data();
|
||||
void ioGetFromData();
|
||||
|
|
@ -447,14 +449,19 @@ public:
|
|||
QSemaphore ready;
|
||||
bool doClose;
|
||||
bool doSsl;
|
||||
bool ipv6;
|
||||
bool multiple;
|
||||
int totalConnections;
|
||||
|
||||
MiniHttpServer(const QByteArray &data, bool ssl = false, QThread *thread = 0)
|
||||
: client(0), dataToTransmit(data), doClose(true), doSsl(ssl),
|
||||
MiniHttpServer(const QByteArray &data, bool ssl = false, QThread *thread = 0, bool useipv6 = false)
|
||||
: client(0), dataToTransmit(data), doClose(true), doSsl(ssl), ipv6(useipv6),
|
||||
multiple(false), totalConnections(0)
|
||||
{
|
||||
listen();
|
||||
if( useipv6 ){
|
||||
listen(QHostAddress::AnyIPv6);
|
||||
}else{
|
||||
listen();
|
||||
}
|
||||
if (thread) {
|
||||
connect(thread, SIGNAL(started()), this, SLOT(threadStartedSlot()));
|
||||
moveToThread(thread);
|
||||
|
|
@ -466,7 +473,7 @@ public:
|
|||
protected:
|
||||
void incomingConnection(int socketDescriptor)
|
||||
{
|
||||
//qDebug() << "incomingConnection" << socketDescriptor;
|
||||
//qDebug() << "incomingConnection" << socketDescriptor << "doSsl:" << doSsl << "ipv6:" << ipv6;
|
||||
if (!doSsl) {
|
||||
client = new QTcpSocket;
|
||||
client->setSocketDescriptor(socketDescriptor);
|
||||
|
|
@ -2326,6 +2333,48 @@ void tst_QNetworkReply::putGetDeleteGetFromHttp()
|
|||
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::connectToIPv6Address_data()
|
||||
{
|
||||
QTest::addColumn<QUrl>("url");
|
||||
QTest::addColumn<QNetworkReply::NetworkError>("error");
|
||||
QTest::addColumn<QByteArray>("dataToSend");
|
||||
QTest::addColumn<QByteArray>("serverVerifyData");
|
||||
QTest::newRow("localhost") << QUrl(QByteArray("http://[::1]")) << QNetworkReply::NoError<< QByteArray("localhost") << QByteArray("\r\nHost: [::1]\r\n");
|
||||
//to add more test data here
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::connectToIPv6Address()
|
||||
{
|
||||
QFETCH(QUrl, url);
|
||||
QFETCH(QNetworkReply::NetworkError, error);
|
||||
QFETCH(QByteArray, dataToSend);
|
||||
QFETCH(QByteArray, serverVerifyData);
|
||||
|
||||
QByteArray httpResponse = QByteArray("HTTP/1.0 200 OK\r\nContent-Length: ");
|
||||
httpResponse += QByteArray::number(dataToSend.size());
|
||||
httpResponse += "\r\n\r\n";
|
||||
httpResponse += dataToSend;
|
||||
|
||||
MiniHttpServer server(httpResponse, false, NULL/*thread*/, true/*useipv6*/);
|
||||
server.doClose = true;
|
||||
|
||||
url.setPort(server.serverPort());
|
||||
QNetworkRequest request(url);
|
||||
|
||||
QNetworkReplyPtr reply = manager.get(request);
|
||||
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
QTestEventLoop::instance().enterLoop(10);
|
||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||
QByteArray content = reply->readAll();
|
||||
if( !serverVerifyData.isEmpty()){
|
||||
//qDebug() << server.receivedData;
|
||||
//QVERIFY(server.receivedData.contains(serverVerifyData)); //got a bug here
|
||||
}
|
||||
QVERIFY(content == dataToSend);
|
||||
QCOMPARE(reply->url(), request.url());
|
||||
QVERIFY(reply->error() == error);
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::sendCustomRequestToHttp_data()
|
||||
{
|
||||
QTest::addColumn<QUrl>("url");
|
||||
|
|
|
|||
Loading…
Reference in New Issue