mirror of
https://github.com/QuasarApp/qthttpserver.git
synced 2025-05-10 00:19:46 +00:00
Fix tests failure introduced by the mime type detection
Commit 4f64330b39bd528a84241e976baa464c6dc89de1 changes some mime types of responses to text/plain. The commit also FIXED the "No newline at end of file" warning in a test data for QHttpServerResponder. Change-Id: I9b6b1878a2b61bf80db1e39b81ae75c4cedce615 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
d542f7e13d
commit
f72ced1671
@ -203,7 +203,7 @@ void tst_QHttpServer::routeGet_data()
|
|||||||
QTest::addRow("hello world")
|
QTest::addRow("hello world")
|
||||||
<< "/"
|
<< "/"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "Hello world get";
|
<< "Hello world get";
|
||||||
|
|
||||||
QTest::addRow("test msg")
|
QTest::addRow("test msg")
|
||||||
@ -221,19 +221,19 @@ void tst_QHttpServer::routeGet_data()
|
|||||||
QTest::addRow("arg:int")
|
QTest::addRow("arg:int")
|
||||||
<< "/page/10"
|
<< "/page/10"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "page: 10";
|
<< "page: 10";
|
||||||
|
|
||||||
QTest::addRow("arg:-int")
|
QTest::addRow("arg:-int")
|
||||||
<< "/page/-10"
|
<< "/page/-10"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "page: -10";
|
<< "page: -10";
|
||||||
|
|
||||||
QTest::addRow("arg:uint")
|
QTest::addRow("arg:uint")
|
||||||
<< "/page/10/detail"
|
<< "/page/10/detail"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "page: 10 detail";
|
<< "page: 10 detail";
|
||||||
|
|
||||||
QTest::addRow("arg:-uint")
|
QTest::addRow("arg:-uint")
|
||||||
@ -245,60 +245,60 @@ void tst_QHttpServer::routeGet_data()
|
|||||||
QTest::addRow("arg:string")
|
QTest::addRow("arg:string")
|
||||||
<< "/user/test"
|
<< "/user/test"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "test";
|
<< "test";
|
||||||
|
|
||||||
QTest::addRow("arg:string")
|
QTest::addRow("arg:string")
|
||||||
<< "/user/test test ,!a+."
|
<< "/user/test test ,!a+."
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "test test ,!a+.";
|
<< "test test ,!a+.";
|
||||||
|
|
||||||
QTest::addRow("arg:string,ba")
|
QTest::addRow("arg:string,ba")
|
||||||
<< "/user/james/bond"
|
<< "/user/james/bond"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "james-bond";
|
<< "james-bond";
|
||||||
|
|
||||||
QTest::addRow("arg:url")
|
QTest::addRow("arg:url")
|
||||||
<< "/test/api/v0/cmds?val=1"
|
<< "/test/api/v0/cmds?val=1"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "path: api/v0/cmds";
|
<< "path: api/v0/cmds";
|
||||||
|
|
||||||
QTest::addRow("arg:float 5.1")
|
QTest::addRow("arg:float 5.1")
|
||||||
<< "/api/v5.1"
|
<< "/api/v5.1"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "api 5.1v";
|
<< "api 5.1v";
|
||||||
|
|
||||||
QTest::addRow("arg:float 5.")
|
QTest::addRow("arg:float 5.")
|
||||||
<< "/api/v5."
|
<< "/api/v5."
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "api 5v";
|
<< "api 5v";
|
||||||
|
|
||||||
QTest::addRow("arg:float 6.0")
|
QTest::addRow("arg:float 6.0")
|
||||||
<< "/api/v6.0"
|
<< "/api/v6.0"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "api 6v";
|
<< "api 6v";
|
||||||
|
|
||||||
QTest::addRow("arg:float,uint")
|
QTest::addRow("arg:float,uint")
|
||||||
<< "/api/v5.1/user/10"
|
<< "/api/v5.1/user/10"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "api 5.1v, user id - 10";
|
<< "api 5.1v, user id - 10";
|
||||||
|
|
||||||
QTest::addRow("arg:float,uint,query")
|
QTest::addRow("arg:float,uint,query")
|
||||||
<< "/api/v5.2/user/11/settings?role=admin" << 200
|
<< "/api/v5.2/user/11/settings?role=admin" << 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "api 5.2v, user id - 11, set settings role=admin#''";
|
<< "api 5.2v, user id - 11, set settings role=admin#''";
|
||||||
|
|
||||||
// The fragment isn't actually sent via HTTP (it's information for the user agent)
|
// The fragment isn't actually sent via HTTP (it's information for the user agent)
|
||||||
QTest::addRow("arg:float,uint, query+fragment")
|
QTest::addRow("arg:float,uint, query+fragment")
|
||||||
<< "/api/v5.2/user/11/settings?role=admin#tag"
|
<< "/api/v5.2/user/11/settings?role=admin#tag"
|
||||||
<< 200 << "text/html"
|
<< 200 << "text/plain"
|
||||||
<< "api 5.2v, user id - 11, set settings role=admin#''";
|
<< "api 5.2v, user id - 11, set settings role=admin#''";
|
||||||
|
|
||||||
QTest::addRow("custom route rule")
|
QTest::addRow("custom route rule")
|
||||||
@ -310,19 +310,19 @@ void tst_QHttpServer::routeGet_data()
|
|||||||
QTest::addRow("custom route rule + query")
|
QTest::addRow("custom route rule + query")
|
||||||
<< "/custom/10?key=11&g=1"
|
<< "/custom/10?key=11&g=1"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "Custom router rule: 10, key=11";
|
<< "Custom router rule: 10, key=11";
|
||||||
|
|
||||||
QTest::addRow("custom route rule + query key req")
|
QTest::addRow("custom route rule + query key req")
|
||||||
<< "/custom/10?g=1&key=12"
|
<< "/custom/10?g=1&key=12"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "Custom router rule: 10, key=12";
|
<< "Custom router rule: 10, key=12";
|
||||||
|
|
||||||
QTest::addRow("post-and-get, get")
|
QTest::addRow("post-and-get, get")
|
||||||
<< "/post-and-get"
|
<< "/post-and-get"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "Hello world get";
|
<< "Hello world get";
|
||||||
|
|
||||||
QTest::addRow("invalid-rule-method, get")
|
QTest::addRow("invalid-rule-method, get")
|
||||||
@ -334,13 +334,13 @@ void tst_QHttpServer::routeGet_data()
|
|||||||
QTest::addRow("check custom type, data=1")
|
QTest::addRow("check custom type, data=1")
|
||||||
<< "/check-custom-type/1"
|
<< "/check-custom-type/1"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "data = 1";
|
<< "data = 1";
|
||||||
|
|
||||||
QTest::addRow("any, get")
|
QTest::addRow("any, get")
|
||||||
<< "/any"
|
<< "/any"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "Get";
|
<< "Get";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ void tst_QHttpServer::routeKeepAlive()
|
|||||||
auto checkReply = [] (QNetworkReply *reply, const QString &response) {
|
auto checkReply = [] (QNetworkReply *reply, const QString &response) {
|
||||||
QTRY_VERIFY(reply->isFinished());
|
QTRY_VERIFY(reply->isFinished());
|
||||||
|
|
||||||
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader), "text/html");
|
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader), "text/plain");
|
||||||
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
|
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
|
||||||
QCOMPARE(reply->readAll(), response);
|
QCOMPARE(reply->readAll(), response);
|
||||||
};
|
};
|
||||||
@ -431,21 +431,21 @@ void tst_QHttpServer::routePost_data()
|
|||||||
QTest::addRow("hello world")
|
QTest::addRow("hello world")
|
||||||
<< "/"
|
<< "/"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< ""
|
<< ""
|
||||||
<< "Hello world post";
|
<< "Hello world post";
|
||||||
|
|
||||||
QTest::addRow("post-and-get, post")
|
QTest::addRow("post-and-get, post")
|
||||||
<< "/post-and-get"
|
<< "/post-and-get"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< ""
|
<< ""
|
||||||
<< "Hello world post";
|
<< "Hello world post";
|
||||||
|
|
||||||
QTest::addRow("any, post")
|
QTest::addRow("any, post")
|
||||||
<< "/any"
|
<< "/any"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< ""
|
<< ""
|
||||||
<< "Post";
|
<< "Post";
|
||||||
|
|
||||||
@ -506,7 +506,7 @@ void tst_QHttpServer::routeDelete_data()
|
|||||||
QTest::addRow("any, delete")
|
QTest::addRow("any, delete")
|
||||||
<< "/any"
|
<< "/any"
|
||||||
<< 200
|
<< 200
|
||||||
<< "text/html"
|
<< "text/plain"
|
||||||
<< "Delete";
|
<< "Delete";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void tst_QHttpServerResponder::writeFile()
|
|||||||
|
|
||||||
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader), type);
|
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader), type);
|
||||||
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), code);
|
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), code);
|
||||||
QCOMPARE(reply->readAll(), data);
|
QCOMPARE(reply->readAll().trimmed(), data);
|
||||||
|
|
||||||
QCOMPARE(spyDestroyIoDevice.count(), 1);
|
QCOMPARE(spyDestroyIoDevice.count(), 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user