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; |
62 |
< |
JavaVMOption options[1]; |
63 |
< |
JNIEnv* env; |
64 |
< |
JavaVM* jvm; |
65 |
< |
JavaVMInitArgs vm_args; |
66 |
< |
long status; |
67 |
< |
jclass cls; |
68 |
< |
jmethodID mid;*/ |
85 |
> |
SOCKET http; |
86 |
|
int begin; |
87 |
|
string page; |
88 |
< |
// void setJarPath(); |
88 |
> |
string type; |
89 |
> |
unsigned length; |
90 |
> |
void error(const string prefix, bool host = false); |
91 |
|
public: |
92 |
|
HttpHandler(); |
93 |
|
~HttpHandler(); |
95 |
|
HttpHandler& getline(string& line, char endline = '\n'); |
96 |
|
bool good(); |
97 |
|
void clear(); |
98 |
+ |
string contentType() { return type; } |
99 |
+ |
unsigned contentLength() { return length; } |
100 |
|
}; |
101 |
|
|
102 |
|
#endif // _HttpHandler_h_ |