|
From: Christian P. <cp...@us...> - 2005-01-07 13:46:30
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5858 Modified Files: Makefile.am Added Files: HTTPClientTest.cpp Log Message: Added HTTPClientTest Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.am 6 Jan 2005 17:01:15 -0000 1.3 +++ Makefile.am 7 Jan 2005 13:46:21 -0000 1.4 @@ -5,7 +5,7 @@ PtrTest_LDADD = $(top_builddir)/src/System/libpclasses_system.la $(top_builddir)/src/libpclasses.la noinst_HEADERS = Test.h noinst_PROGRAMS = QueueTest StackTest IntTypeTest ListTest ThreadTest \ - StringTest IOTest SignalTest + StringTest IOTest SignalTest HTTPClientTest QueueTest_SOURCES = QueueTest.cpp QueueTest_LDADD = $(top_builddir)/src/libpclasses.la StackTest_SOURCES = StackTest.cpp @@ -24,3 +24,6 @@ IOTest_LDADD = $(top_builddir)/src/System/libpclasses_system.la \ $(top_builddir)/src/IO/libpclasses_io.la $(top_builddir)/src/libpclasses.la -lz SignalTest_SOURCES = SignalTest.cpp +HTTPClientTest_SOURCES = HTTPClientTest.cpp +HTTPClientTest_LDADD = $(top_builddir)/src/Net/libpclasses_net.la\ + $(top_builddir)/src/libpclasses.la --- NEW FILE: HTTPClientTest.cpp --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "Test.h" #include "pclasses/IO/URL.h" #include "pclasses/IO/ZLibIOFilter.h" #include "pclasses/Net/HTTPClient.h" #include "pclasses/Net/InetAddress.h" #include <limits.h> namespace P { class HTTPClientTest: public UnitTest { public: void run() throw() { Net::HTTPClient cl; cl.open(Net::Socket::Inet); std::cerr << "Connecting to 192.168.1.1..." << std::endl; cl.connect(Net::InetAddress("217.160.172.188"), 80); std::cerr << "Sending request ..." << std::endl; Net::HTTPRequest req(Net::HTTPRequest::GET, IO::URL("http://192.168.1.1/")); cl.sendRequest(req); std::cerr << "Reading response ..." << std::endl; Net::HTTPResponse resp = cl.readResponse(); std::cerr << "Response: " << resp.protocol() << ' ' << resp.responseCode() << ' ' << resp.response() << std::endl; while(!resp.eof()) { char tmp[1024]; size_t count = resp.read(tmp, 1024); std::cerr.write(tmp, count); } } }; } int main(int argc, char* argv[]) { P::HTTPClientTest httpct; httpct.run(); return 0; } |