Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43f55df516 | ||
|
|
f70405e4d6 | ||
|
|
4b2705fb32 | ||
|
|
b85aa4b246 | ||
|
|
d05bdd3ec2 | ||
|
|
e01c0f23c0 | ||
|
|
ada6c53130 | ||
|
|
c06432caef | ||
|
|
f56b19513b | ||
|
|
c2b21cdca4 | ||
|
|
9652e8f508 |
@@ -8,12 +8,12 @@ compiler:
|
||||
- gcc
|
||||
|
||||
install:
|
||||
- sudo add-apt-repository -y ppa:beineri/opt-qt58-trusty
|
||||
- sudo add-apt-repository -y ppa:beineri/opt-qt592-trusty
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq cmake qt58base
|
||||
- sudo apt-get install -qq cmake qt59base
|
||||
|
||||
before_script:
|
||||
- export PATH=$PATH:/opt/qt58/bin
|
||||
- export PATH=$PATH:/opt/qt59/bin
|
||||
|
||||
script:
|
||||
- cmake -DBUILD_TESTS=on .
|
||||
|
||||
@@ -8,9 +8,12 @@ set(PROJECT_URL "https://github.com/nitroshare/qhttpengine")
|
||||
|
||||
set(PROJECT_VERSION_MAJOR 1)
|
||||
set(PROJECT_VERSION_MINOR 0)
|
||||
set(PROJECT_VERSION_PATCH 0)
|
||||
set(PROJECT_VERSION_PATCH 1)
|
||||
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
|
||||
# Build a shared library by default
|
||||
option(BUILD_SHARED_LIBS "Build QHttpEngine as a shared library" ON)
|
||||
|
||||
set(BIN_INSTALL_DIR bin CACHE STRING "Binary runtime installation directory relative to the install prefix")
|
||||
set(LIB_INSTALL_DIR lib CACHE STRING "Library installation directory relative to the install prefix")
|
||||
set(INCLUDE_INSTALL_DIR include CACHE STRING "Header installation directory relative to the install prefix")
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
find_package(Doxygen REQUIRED)
|
||||
|
||||
configure_file(Doxyfile.in "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
|
||||
|
||||
add_custom_target(doc ALL
|
||||
|
||||
@@ -47,7 +47,4 @@ void ApiHandler::messagesNew(QHttpEngine::Socket *socket)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If execution reaches this point, malformed data was supplied
|
||||
socket->writeError(QHttpEngine::Socket::BadRequest);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ if(WIN32)
|
||||
set(SRC ${SRC} "${CMAKE_CURRENT_BINARY_DIR}/resource.rc")
|
||||
endif()
|
||||
|
||||
add_library(qhttpengine SHARED ${HEADERS} ${SRC})
|
||||
add_library(qhttpengine ${HEADERS} ${SRC})
|
||||
|
||||
set_target_properties(qhttpengine PROPERTIES
|
||||
CXX_STANDARD 11
|
||||
|
||||
@@ -6,5 +6,6 @@ Name: @PROJECT_NAME@
|
||||
Description: @PROJECT_DESCRIPTION@
|
||||
URL: @PROJECT_URL@
|
||||
Version: @PROJECT_VERSION@
|
||||
Requires: Qt5Network
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lqhttpengine
|
||||
|
||||
@@ -30,10 +30,16 @@
|
||||
#define QHTTPENGINE_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define QHTTPENGINE_VERSION "@PROJECT_VERSION@"
|
||||
|
||||
#if defined(QHTTPENGINE_LIBRARY)
|
||||
# define QHTTPENGINE_EXPORT Q_DECL_EXPORT
|
||||
#cmakedefine BUILD_SHARED_LIBS
|
||||
|
||||
#if defined(BUILD_SHARED_LIBS)
|
||||
# if defined(QHTTPENGINE_LIBRARY)
|
||||
# define QHTTPENGINE_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define QHTTPENGINE_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define QHTTPENGINE_EXPORT Q_DECL_IMPORT
|
||||
# define QHTTPENGINE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // QHTTPENGINE_QHTTPENGINE_H
|
||||
|
||||
@@ -68,7 +68,7 @@ SocketPrivate::SocketPrivate(Socket *httpSocket, QTcpSocket *tcpSocket)
|
||||
|
||||
connect(socket, &QTcpSocket::readyRead, this, &SocketPrivate::onReadyRead);
|
||||
connect(socket, &QTcpSocket::bytesWritten, this, &SocketPrivate::onBytesWritten);
|
||||
connect(socket, &QTcpSocket::readChannelFinished, q, &Socket::readChannelFinished);
|
||||
connect(socket, &QTcpSocket::readChannelFinished, this, &SocketPrivate::onReadChannelFinished);
|
||||
connect(socket, &QTcpSocket::disconnected, q, &Socket::disconnected);
|
||||
|
||||
// Process anything already received by the socket
|
||||
@@ -137,6 +137,13 @@ void SocketPrivate::onBytesWritten(qint64 bytes)
|
||||
}
|
||||
}
|
||||
|
||||
void SocketPrivate::onReadChannelFinished()
|
||||
{
|
||||
if (requestDataTotal == -1) {
|
||||
emit q->readChannelFinished();
|
||||
}
|
||||
}
|
||||
|
||||
bool SocketPrivate::readHeaders()
|
||||
{
|
||||
// Check for the double CRLF that signals the end of the headers and
|
||||
|
||||
@@ -73,6 +73,7 @@ private Q_SLOTS:
|
||||
|
||||
void onReadyRead();
|
||||
void onBytesWritten(qint64 bytes);
|
||||
void onReadChannelFinished();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -132,9 +132,9 @@ void TestSocket::testSignals()
|
||||
|
||||
QSignalSpy headersParsedSpy(server, SIGNAL(headersParsed()));
|
||||
QSignalSpy readyReadSpy(server, SIGNAL(readyRead()));
|
||||
QSignalSpy readChannelFinishedSpy(server, SIGNAL(readChannelFinished()));
|
||||
QSignalSpy bytesWrittenSpy(server, SIGNAL(bytesWritten(qint64)));
|
||||
QSignalSpy aboutToCloseSpy(server, SIGNAL(aboutToClose()));
|
||||
QSignalSpy readChannelFinishedSpy(server, SIGNAL(readChannelFinished()));
|
||||
|
||||
client.sendHeaders(Method, Path, headers);
|
||||
|
||||
@@ -145,7 +145,6 @@ void TestSocket::testSignals()
|
||||
|
||||
QTRY_COMPARE(server->bytesAvailable(), Data.length());
|
||||
QVERIFY(readyReadSpy.count() > 0);
|
||||
QCOMPARE(readChannelFinishedSpy.count(), 1);
|
||||
|
||||
server->writeHeaders();
|
||||
server->write(Data);
|
||||
@@ -162,6 +161,8 @@ void TestSocket::testSignals()
|
||||
QTRY_COMPARE(aboutToCloseSpy.count(), 0);
|
||||
server->close();
|
||||
QTRY_COMPARE(aboutToCloseSpy.count(), 1);
|
||||
|
||||
QCOMPARE(readChannelFinishedSpy.count(), 1);
|
||||
}
|
||||
|
||||
void TestSocket::testJson()
|
||||
|
||||
Reference in New Issue
Block a user