PDA

View Full Version : Build an HTTP server



the_bis
29th March 2007, 10:47
Is there a way to embed an HTTP server into my QT4 cross-platform (Linux and Win) application?
I'd like to answer to GET/POST requests from the net when my application is running.

Can I use QHTTP or I have to use an external library? Any suggestion?

Thanks,
the_bis

camel
29th March 2007, 11:23
You would have to write it yourself, as QHttp is client only..

What do you need it for?
(I have written a Qt4 Http-Server, but it is not as complete, not documented as I would like...but maybe you could use it...depending on your use-case...)

the_bis
29th March 2007, 11:40
You would have to write it yourself, as QHttp is client only..
Ok, so this is the problem.


What do you need it for?
I have to answer to "wget" command request to distribute binary files. Very very simple.


(I have written a Qt4 Http-Server, but it is not as complete, not documented as I would like...but maybe you could use it...depending on your use-case...)
This is very interesting, thanks. I can try to use it in my application.
Before you send me the code you have to know that maybe, in the future, my application will be a closed QT application (not opensource)...

Let me say if you agree with me and if you can send me the source code,
thanks again,
the_bis

camel
29th March 2007, 11:51
I have to answer to "wget" command request to distribute binary files. Very very simple.


Ok, the GET part is really easy, you would not need the server I have written for it, as it would be overkill. (I would imaging you do not need pipelining/multithreadding and all that stuff ;-)

But a very simple server (tailored to your needs) is not too hard to write:

Create a TcpServer,
listen for requests,
read the request,
parse the request using QHttpRequestHeader,
analyze it,
send the response header
send the file (i.e. read from a qfile and copy the bytes to the socket)
close the connection


To learn a bit about Http check out this page: HTTP Made Really Easy (http://www.jmarshall.com/easy/http/)




This is very interesting, thanks. I can try to use it in my application.
Before you send me the code you have to know that maybe, in the future, my application will be a closed QT application (not opensource)...


There would be a problem since my server is (and will stay that way at least until I am satisfied with it) under the GPL.

the_bis
30th March 2007, 07:36
Ok, the GET part is really easy, you would not need the server I have written for it, as it would be overkill. (I would imaging you do not need pipelining/multithreadding and all that stuff ;-)

But a very simple server (tailored to your needs) is not too hard to write:

Create a TcpServer,
listen for requests,
read the request,
parse the request using QHttpRequestHeader,
analyze it,
send the response header
send the file (i.e. read from a qfile and copy the bytes to the socket)
close the connection


To learn a bit about Http check out this page: HTTP Made Really Easy (http://www.jmarshall.com/easy/http/)


Ok, thank you very much.


There would be a problem since my server is (and will stay that way at least until I am satisfied with it) under the GPL.

I understand and I agree with your choice :)

Bye,
the_bis