1 // httpd.hxx -- FGFS http property manager interface / external script
4 // Written by Curtis Olson, started June 2001.
6 // Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 #include <plib/netChat.h>
34 #include "protocol.hxx"
37 /* simple httpd server that makes an hasty stab at following the http
40 class HttpdChannel : public netChat
47 HttpdChannel() : buffer(512) { setTerminator("\r\n"); }
49 virtual void collectIncomingData (const char* s, int n) {
53 // Handle the actual http request
54 virtual void foundTerminator (void);
58 class HttpdServer : private netChannel
60 virtual bool writable (void) { return false ; }
62 virtual void handleAccept (void) {
64 int handle = accept ( &addr ) ;
65 printf("Client %s:%d connected\n", addr.getHost(), addr.getPort());
67 HttpdChannel *hc = new HttpdChannel;
68 hc->setHandle ( handle ) ;
73 HttpdServer ( int port ) {
78 printf ( "Httpd server started on port %d\n", port ) ;
83 class FGHttpd : public FGProtocol {
90 inline FGHttpd( int p ) { port = p; }
102 #endif // _FG_HTTPD_HXX