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 18 by douglas, 2002-12-09T21:40:12-08:00

# Line 53 | Line 53
53  
54   #include "Search.h"
55   #include "URL.h"
56 < //#include <jni.h>
56 >
57 > // Lovely C Sockets!
58 > #ifdef _WIN32
59 >
60 > // Windows Sockets
61 > #include <winsock2.h>
62 > #include <windows.h>
63 >
64 > #else
65 >
66 > // BSD Sockets
67 > #include <unistd.h>
68 > #include <sys/types.h>
69 > #include <sys/socket.h>
70 > #include <netinet/in.h>
71 > #include <netdb.h>
72 >
73 > #define INVALID_SOCKET -1
74 > #define SOCKET_ERROR -1
75 >
76 > typedef int SOCKET;
77 >
78 > inline int closesocket(SOCKET s) { return close(s); }
79 >
80 > #endif // _WIN32
81  
82   class HttpHandler
83   {
84   private:
85 < /*      char* jarPath;
86 <        JavaVMOption options[1];
87 <        JNIEnv* env;
88 <        JavaVM* jvm;
89 <        JavaVMInitArgs vm_args;
90 <        long status;
91 <        jclass cls;
92 <        jmethodID mid;*/
69 <        int begin;
85 >        enum code {ok = 200, choices = 300, moved = 301, found = 302, notfound =
86 >                404, internal = 500};
87 > #ifdef _WIN32
88 >        WSADATA data;
89 > #endif // _WIN32
90 >        SOCKET http;
91 >        char* buffer;
92 >        unsigned begin;
93          string page;
94 <        void setJarPath();
94 >        string type;
95 >        unsigned length;
96 >        string location;
97 >        bool chunked;
98 >        void putline(const string line = "");
99 >        string getline();
100 >        void error(const string& prefix, bool host = false);
101   public:
102          HttpHandler();
103          ~HttpHandler();
104 <        bool connect(URL& url);
104 >        bool handle(URL& url, bool head = false);
105          HttpHandler& getline(string& line, char endline = '\n');
106          bool good();
107          void clear();
108 +        string contentType() { return type; }
109 +        unsigned contentLength() { return length; }
110 +        string redirect() { return location; }
111   };
112  
113   #endif // _HttpHandler_h_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines