qhttpserver-master
所属分类:网络编程
开发工具:QT
文件大小:106KB
下载次数:12
上传日期:2017-11-04 12:40:33
上 传 者:
4518927
说明: qt版http服务器,基于qt5.5.1的封装类库
(QT version HTTP server)
文件列表:
LICENSE (1087, 2016-10-29)
TODO (357, 2016-10-29)
docs (0, 2016-10-29)
docs\Doxyfile (100782, 2016-10-29)
docs\pages (0, 2016-10-29)
docs\pages\examples.dox (196, 2016-10-29)
docs\pages\main-page.dox (3538, 2016-10-29)
examples (0, 2016-10-29)
examples\bodydata (0, 2016-10-29)
examples\bodydata\bodydata.cpp (1769, 2016-10-29)
examples\bodydata\bodydata.h (576, 2016-10-29)
examples\bodydata\bodydata.pro (263, 2016-10-29)
examples\examples.pro (64, 2016-10-29)
examples\greeting (0, 2016-10-29)
examples\greeting\greeting.cpp (1158, 2016-10-29)
examples\greeting\greeting.h (218, 2016-10-29)
examples\greeting\greeting.pro (263, 2016-10-29)
examples\helloworld (0, 2016-10-29)
examples\helloworld\helloworld.cpp (787, 2016-10-29)
examples\helloworld\helloworld.h (224, 2016-10-29)
examples\helloworld\helloworld.pro (269, 2016-10-29)
http-parser (0, 2016-10-29)
http-parser\.mailmap (480, 2016-10-29)
http-parser\.travis.yml (132, 2016-10-29)
http-parser\AUTHORS (2468, 2016-10-29)
http-parser\LICENSE-MIT (1251, 2016-10-29)
http-parser\bench.c (3400, 2016-10-29)
http-parser\contrib (0, 2016-10-29)
http-parser\contrib\parsertrace.c (4352, 2016-10-29)
http-parser\contrib\url_parser.c (1122, 2016-10-29)
http-parser\http_parser.c (70351, 2016-10-29)
http-parser\http_parser.gyp (2855, 2016-10-29)
http-parser\http_parser.h (12991, 2016-10-29)
http-parser\test.c (103031, 2016-10-29)
qhttpserver.pri (128, 2016-10-29)
... ...
QHttpServer is NOT actively maintained. [Amir Zamani](https://github.com/azadkuh)'s [qhttp](https://github.com/azadkuh/qhttp) fixes some of the bugs here and is generally a nicer place to start from.
QHttpServer
===========
A Qt HTTP Server - because hard-core programmers write web-apps in C++ :)
It uses Joyent's [HTTP Parser](http://github.com/joyent/http-parser) and is asynchronous and does not require any inheritance.
QHttpServer is available under the MIT License.
**NOTE: QHttpServer is NOT fully HTTP compliant right now! DO NOT use it for
anything complex**
Installation
------------
Requires Qt 4 or Qt 5.
qmake && make && su -c 'make install'
To link to your projects put this in your project's qmake project file
LIBS += -lqhttpserver
By default, the installation prefix is /usr/local. To change that to /usr,
for example, run:
qmake -r PREFIX=/usr
Usage
-----
Include the headers
#include
#include
#include
Create a server, and connect to the signal for new requests
QHttpServer *server = new QHttpServer;
connect(server, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*)),
handler, SLOT(handle(QHttpRequest*, QHttpResponse*)));
// let's go
server->listen(8080);
In the handler, you may dispatch on routes or do whatever other things
you want. See the API documentation for what information
is provided about the request via the QHttpRequest object.
To send data back to the browser and end the request:
void Handler::handle(QHttpRequest *req, QHttpResponse *resp)
{
resp->setHeader("Content-Length", 11);
resp->writeHead(200); // everything is OK
resp->write("Hello World");
resp->end();
}
The server and request/response objects emit various signals
and have guarantees about memory management. See the API documentation for
these.
Contribute
----------
Feel free to file issues, branch and send pull requests. If you plan to work on a major feature (say WebSocket support), please run it by me first by filing an issue! qhttpserver has a narrow scope and API and I'd like to keep it that way, so a thousand line patch that implements the kitchen sink is unlikely to be accepted.
- Nikhil Marathe (maintainer)
Everybody who has ever contributed shows up in [Contributors](https://github.com/nikhilm/qhttpserver/graphs/contributors).
近期下载者:
相关文件:
收藏者: