summaryrefslogtreecommitdiff
path: root/src/Sockets/tests/sloppy_http.cpp
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2008-10-19 20:06:14 +0000
committerOthmar Gsenger <otti@anytun.org>2008-10-19 20:06:14 +0000
commit7ec2d1c53b753238509bf7a89587509305b9216d (patch)
tree2e81d3fbd6b2a515f71449a2a16b2c69ecf4ddad /src/Sockets/tests/sloppy_http.cpp
parentswitched from PracticalSocket to libasio (diff)
move to asio socket libary for sync
bugs / todos: * new connections don't sync * anyrtpproxy broken * anytun-controlld doesn't send data
Diffstat (limited to 'src/Sockets/tests/sloppy_http.cpp')
-rw-r--r--src/Sockets/tests/sloppy_http.cpp55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/Sockets/tests/sloppy_http.cpp b/src/Sockets/tests/sloppy_http.cpp
deleted file mode 100644
index 9ea79c1..0000000
--- a/src/Sockets/tests/sloppy_http.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <SocketHandler.h>
-#include <TcpSocket.h>
-
-
-class GetHttp : public TcpSocket
-{
-public:
- GetHttp(ISocketHandler& h, const char *request) : TcpSocket(h)
- , m_request(request) {}
-
- void OnConnect() {
- Send( m_request );
- }
-
- void OnRawData( const char *buf, size_t len ) {
- if (len > 0) {
- std::string tmp;
- tmp.resize( len );
- memcpy( &tmp[0], buf, len );
- m_response += tmp;
- }
- }
-
- const std::string& Response() {
- return m_response;
- }
-
-private:
- std::string m_request;
- std::string m_response;
-};
-
-
-std::string get_http(const char *host, int port, const char *request)
-{
- SocketHandler h;
- GetHttp sock(h, request);
- sock.Open( host, port );
- h.Add(&sock);
- while (h.GetCount()) {
- h.Select(1, 0);
- }
- return sock.Response();
-}
-
-
-int main(int argc, char *argv[])
-{
- std::string zz = get_http("www.alhem.net", 80, "GET /index.html HTTP/1.0\r\n"
- "Host: www.alhem.net\r\n"
- "\r\n");
- printf("%s\n%d\n", zz.c_str(), zz.size());
-}
-
-