ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Search/HttpHandler.h
(Generate patch)

Comparing trunk/Search/HttpHandler.h (file contents):
Revision 1 by douglas, 2002-12-04T20:22:59-08:00 vs.
Revision 211 by douglas, 2003-07-19T18:46:12-07:00

# Line 1 | Line 1
1   /* ============================================================================
2   * Douglas Thrift's Search Engine License
3   *
4 < * Copyright (C) 2002, Douglas Thrift. All Rights Reserved.
4 > * Copyright (C) 2002-2003, Douglas Thrift. All Rights Reserved.
5   * Redistribution and use in source and binary forms, with or without
6   * modification, are permitted provided that the following conditions are met:
7   *
# Line 46 | Line 46
46   //
47   // Douglas Thrift
48   //
49 < // HttpHandler.h
49 > // $Id: HttpHandler.h,v 1.18 2003/07/20 01:46:12 douglas Exp $
50  
51   #ifndef _HttpHandler_h_
52   #define _HttpHandler_h_
53  
54   #include "Search.h"
55   #include "URL.h"
56 < //#include <jni.h>
56 >
57 > // Lovely C Sockets!
58 > #ifdef _WIN32
59 > // Windows Sockets
60 > #include <winsock2.h>
61 > #include <windows.h>
62 >
63 > inline int getpid() { return GetCurrentProcessId(); }
64 > #else
65 > // BSD Sockets
66 > typedef int SOCKET;
67 >
68 > #define INVALID_SOCKET -1
69 > #define SOCKET_ERROR -1
70 >
71 > inline int closesocket(SOCKET s) { return close(s); }
72 > #endif // _WIN32
73 >
74 > #ifdef _OpenSSL_
75 > #include <openssl/ssl.h>
76 > #include <openssl/err.h>
77 > #include <openssl/rand.h>
78 > #endif
79  
80   class HttpHandler
81   {
82   private:
83 < /*      char* jarPath;
84 <        JavaVMOption options[1];
85 <        JNIEnv* env;
86 <        JavaVM* jvm;
87 <        JavaVMInitArgs vm_args;
88 <        long status;
89 <        jclass cls;
90 <        jmethodID mid;*/
91 <        int begin;
92 <        string page;
93 <        void setJarPath();
83 >        enum code {ok = 200, choices = 300, moved = 301, found = 302, notfound =
84 >                404, internal = 500};
85 > #ifdef _WIN32
86 >        WSADATA data;
87 > #endif // _WIN32
88 >        SOCKET http;
89 > #ifdef _OpenSSL_
90 >        SSL_CTX* ctx;
91 >        SSL* ssl;
92 >        bool tls;
93 > #endif
94 >        char* buffer;
95 >        bool binary;
96 >        stringstream page;
97 >        string type;
98 >        unsigned length;
99 >        string location;
100 >        bool chunked;
101 >        void populate();
102 >        void putline(const string line = "");
103 >        string getline();
104 >        void error(const string& prefix, bool host = false);
105 > #ifdef _OpenSSL_
106 >        void error(const string& prefix, int number);
107 >        bool starttls();
108 > #endif
109   public:
110          HttpHandler();
111          ~HttpHandler();
112 <        bool connect(URL& url);
113 <        HttpHandler& getline(string& line, char endline = '\n');
114 <        bool good();
112 >        bool handle(URL& url, const string referer = "", bool head = false);
113 >        iostream& pageStream() { return page; }
114 >        istream& getline(string& line) { return std::getline(page, line); }
115 >        istream& getline(string& line, char end) { return std::getline(page, line,
116 >                end); }
117 >        bool good() { return page.good(); }
118          void clear();
119 +        string contentType() { return type; }
120 +        unsigned contentLength() { return length; }
121 +        string redirect() { return location; }
122   };
123  
124   #endif // _HttpHandler_h_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines