summaryrefslogtreecommitdiff
path: root/src/Sockets/tests/https.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/https.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/https.cpp')
-rw-r--r--src/Sockets/tests/https.cpp113
1 files changed, 0 insertions, 113 deletions
diff --git a/src/Sockets/tests/https.cpp b/src/Sockets/tests/https.cpp
deleted file mode 100644
index 45b36ff..0000000
--- a/src/Sockets/tests/https.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <HTTPSocket.h>
-#include <SocketHandler.h>
-#include <ListenSocket.h>
-#include <Exception.h>
-
-
-class tSocket : public HTTPSocket
-{
-public:
- tSocket(ISocketHandler& h) : HTTPSocket(h)
- , m_first(false)
- , m_sz(0) {
- EnableSSL();
- }
-
- tSocket(ISocketHandler& h, const std::string& host) : HTTPSocket(h), m_host(host)
- , m_first(false)
- , m_sz(0) {
- EnableSSL();
- Open(host, 4443);
- }
-
- void InitSSLServer() {
- InitializeContext("", "comb.pem", "", SSLv23_method());
- }
-
- void OnSSLAccept() {
- printf("OnSSLAccept()\n");
- HTTPSocket::OnSSLAccept();
- }
-
- void OnSSLConnect() {
- printf("OnSSLConnect()\n");
- HTTPSocket::OnSSLConnect();
- }
-
- void OnAccept() {
-printf("OnAccept\n");
- }
-
- void OnConnect() {
-printf("OnConnect\n");
- Send("GET /index.html HTTP/1.0\r\n");
- Send("Host: " + m_host + "\r\n");
- Send("\r\n");
- }
-
- void OnFirst() {
- }
-
- void OnHeader(const std::string& key, const std::string& value) {
- fprintf(stderr, "%s: %s\n", key.c_str(), value.c_str());
- }
-
- void OnHeaderComplete() {
- fprintf(stderr, "\n");
- }
-
- void OnData(const char *buf, size_t sz) {
- if (1||!m_first)
- {
- std::string str = buf;
- str.resize( sz );
- printf("%s", str.c_str());
- m_first = true;
- }
- m_sz += sz;
- }
-
- void OnDelete() {
- fprintf(stderr, "Content length: %d\n", m_sz);
- }
-
-private:
- std::string m_host;
- bool m_first;
- size_t m_sz;
-};
-
-
-int main(int argc, char *argv[])
-{
- try
- {
- SocketHandler h;
- if (argc > 1 && !strcmp(argv[1], "-server"))
- {
- ListenSocket<tSocket> l(h);
- l.Bind(4443);
- h.Add(&l);
- while (h.GetCount())
- {
- h.Select(1, 0);
- }
- }
- else
- {
- std::string host = argc > 1 ? argv[1] : "www.alhem.net";
- tSocket sock(h, host);
- h.Add(&sock);
- while (h.GetCount())
- {
- h.Select(1, 0);
- }
- }
- }
- catch (const Exception& e)
- {
- printf("%s\n", e.ToString().c_str());
- }
-}
-
-