11 Commits

Author SHA1 Message Date
Nathan Osman
43f55df516 Fix link type mismatch on Windows and build a shared library by default. 2018-03-22 13:14:00 -07:00
Nathan Osman
f70405e4d6 Merge pull request #25 from tonytheodore/master
Re-enable static builds
2018-03-16 23:12:06 -07:00
Tony Theodore
4b2705fb32 Require Qt5Network in pkg-config file 2018-03-15 19:24:38 +11:00
Tony Theodore
b85aa4b246 Enable static builds
If unspecified, `add_library` uses the value from cmake's builtin `BUILD_SHARED_LIBS` (default true).
2018-03-15 18:47:38 +11:00
Tony Theodore
d05bdd3ec2 Use QT_STATIC to define QHTTPENGINE_EXPORT 2018-03-15 18:45:08 +11:00
Nathan Osman
e01c0f23c0 Bump patch version. 2017-11-29 18:03:00 -08:00
Nathan Osman
ada6c53130 Correct typo in package names. 2017-11-06 22:21:32 -08:00
Nathan Osman
c06432caef Update test environment to Qt 5.9.2. 2017-11-06 22:17:21 -08:00
Nathan Osman
f56b19513b Remove unnecessary code from chat example. 2017-10-25 20:06:27 -07:00
Nathan Osman
c2b21cdca4 Ensure readChannelFinished() is only emitted once (fixes #21). 2017-10-25 19:31:54 -07:00
Nathan Osman
9652e8f508 Remove unnecessary line. 2017-09-07 15:33:06 -07:00
10 changed files with 30 additions and 16 deletions

View File

@@ -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 .

View File

@@ -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")

View File

@@ -1,5 +1,3 @@
find_package(Doxygen REQUIRED)
configure_file(Doxyfile.in "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
add_custom_target(doc ALL

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -73,6 +73,7 @@ private Q_SLOTS:
void onReadyRead();
void onBytesWritten(qint64 bytes);
void onReadChannelFinished();
private:

View File

@@ -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()