JunkBox_Lib  1.10.2
http_tool.h
Go to the documentation of this file.
1 #ifndef __JBXL_HTTP_TOOL_H_
2 #define __JBXL_HTTP_TOOL_H_
3 
13 #include "txml.h"
14 #include "protocol.h"
15 
16 
17 #ifndef DISABLE_ZLIB
18  #include "gz_tool.h"
19 #endif
20 
21 
22 #define HTTP_CONNECTION_CLOSE 0
23 #define HTTP_CONNECTION_KEEP 1
24 #define HTTP_HEADER_NOT_HTTP -1990
25 #define HTTP_HEADER_CLOSED_SESSION -1997
26 #define HTTP_HEADER_CHUNKED -1998
27 #define HTTP_HEADER_UNKNOWN_LEN -1999
28 
29 //
30 #define HTTP_ERROR_METHOD -1
31 #define HTTP_UNKNOWN_METHOD 0
32 
33 // HTTP
34 #define HTTP_GET_METHOD 1
35 #define HTTP_PUT_METHOD 2
36 #define HTTP_POST_METHOD 3
37 #define HTTP_DELETE_METHOD 4
38 #define HTTP_OPTIONS_METHOD 5
39 #define HTTP_HEAD_METHOD 6
40 #define HTTP_TRACE_METHOD 7
41 #define HTTP_CONNECT_METHOD 8
42 #define HTTP_PATCH_METHOD 9
43 #define HTTP_LINK_METHOD 10
44 #define HTTP_UNLINK_METHOD 11
45 
46 // WebDAV
47 #define HTTP_PROPFIND_METHOD 20
48 #define HTTP_PROPPATCH_METHOD 21
49 #define HTTP_MKCOL_METHOD 22
50 #define HTTP_COPY_METHOD 23
51 #define HTTP_MOVE_METHOD 24
52 #define HTTP_LOCK_METHOD 25
53 #define HTTP_UNLOCK_METHOD 26
54 
55 #define HTTP_RESPONSE_METHOD 99
56 
57 #define HTTP_TIMEOUT 60
58 #define HTTP_RESPONSE_TIMEOUT 180
59 #define HTTP_PROXY_TIMEOUT 60
60 
61 
62 int recv_http_header(int sock, tList** pl, int* len, int tm, FILE* fp, int* state);
63 int send_http_header(int sock, tList* pl, int mode);
64 
65 int recv_http_content(int sofd, Buffer* buf, int len, int tm, FILE* fp, int* state);
66 int recv_http_chunked(int sofd, Buffer* buf, int tm, FILE* fp, int* state);
67 int recv_http_closed (int sofd, Buffer* buf, int tm, FILE* fp);
68 
69 int recv_http_chunked_remain(int sofd, Buffer* buf, int chnksz, int tm);
70 
71 int recv_http_Buffer(int sock, tList** pl, Buffer* buf, int timeout, int* hdonly, int* state, int nochunk);
72 int send_http_Buffer(int sock, tList* pl, Buffer* buf);
73 
74 int recv_http_file(int sock, tList** pl, const char* fn, const char* wdir, int timeout, int* hdonly, int* state);
75 int send_http_file(int sock, tList* pl, const char* fn);
76 
77 int save_http_xml(int sock, tList** pl, tXML** xml, char** recvfn, const char* wdir, int timeout, int* state);
78 
80 // Tools
81 int get_http_method(char* data);
82 
83 int is_http_header_field(tList* pl, char* field, char* value, int n);
85 void set_http_host_header(tList* pl, char* hname, unsigned short hport);
86 void dump_http_header(FILE* fp, tList* pp);
87 
88 int get_http_status_num(tList* pl);
89 float get_http_version_num(tList* pl);
90 
91 int get_chunked_size(char* ptr, int* hdsz, int* tlsz);
92 
93 char* get_http_header_date(time_t tm); // need free()
94 Buffer rebuild_http_Buffer(tList* pl, Buffer* buf); // need free()
95 
97 // HTTP Proxy
98 void simple_web_proxy(int bofd, char* myip, int tmout);
99 int www2browser_relay(int bofd, int wofd, int btm, int wtm, int keep);
100 Buffer http_proxy_header_analyze(tList* pl, Buffer* server, unsigned short* sport, int* timeout, int* keep);
101 
103 // Alternative Tools
104 int tcp_relay(int sofd, int cofd, int tm);
105 
107 // Server Side (Junk Code)
108 int send_http_res_file(int sock, char* fn, int mode);
109 void send_http_passwd_req(int sock);
110 
111 
112 #endif // __JBXL_HTTP_TOOL_H_
113 
gzツールプログラム ヘッダ (-lz)
Buffer rebuild_http_Buffer(tList *pl, Buffer *buf)
Definition: http_tool.c:74
int get_http_header_method(tList *pl)
Definition: http_tool.c:898
int get_chunked_size(char *ptr, int *hdsz, int *tlsz)
Definition: http_tool.c:981
int recv_http_chunked(int sofd, Buffer *buf, int tm, FILE *fp, int *state)
Definition: http_tool.c:410
int send_http_res_file(int sock, char *fn, int mode)
Definition: http_tool.c:1457
int tcp_relay(int sofd, int cofd, int tm)
Definition: http_tool.c:1336
int save_http_xml(int sock, tList **pl, tXML **xml, char **recvfn, const char *wdir, int timeout, int *state)
Definition: http_tool.c:797
int send_http_Buffer(int sock, tList *pl, Buffer *buf)
Definition: http_tool.c:116
void dump_http_header(FILE *fp, tList *pp)
Definition: http_tool.c:942
int recv_http_file(int sock, tList **pl, const char *fn, const char *wdir, int timeout, int *hdonly, int *state)
Definition: http_tool.c:667
void simple_web_proxy(int bofd, char *myip, int tmout)
Definition: http_tool.c:1044
int recv_http_Buffer(int sock, tList **pl, Buffer *buf, int timeout, int *hdonly, int *state, int nochunk)
Definition: http_tool.c:577
int send_http_header(int sock, tList *pl, int mode)
Definition: http_tool.c:56
int get_http_method(char *data)
Definition: http_tool.c:837
int recv_http_chunked_remain(int sofd, Buffer *buf, int chnksz, int tm)
Definition: http_tool.c:489
void send_http_passwd_req(int sock)
Definition: http_tool.c:1506
int is_http_header_field(tList *pl, char *field, char *value, int n)
Definition: http_tool.c:877
int recv_http_header(int sock, tList **pl, int *len, int tm, FILE *fp, int *state)
Definition: http_tool.c:240
Buffer http_proxy_header_analyze(tList *pl, Buffer *server, unsigned short *sport, int *timeout, int *keep)
Definition: http_tool.c:1164
char * get_http_header_date(time_t tm)
Definition: http_tool.c:1015
int recv_http_content(int sofd, Buffer *buf, int len, int tm, FILE *fp, int *state)
Definition: http_tool.c:361
float get_http_version_num(tList *pl)
Definition: http_tool.c:1421
int recv_http_closed(int sofd, Buffer *buf, int tm, FILE *fp)
Definition: http_tool.c:529
void set_http_host_header(tList *pl, char *hname, unsigned short hport)
Definition: http_tool.c:917
int get_http_status_num(tList *pl)
Definition: http_tool.c:1401
int send_http_file(int sock, tList *pl, const char *fn)
Definition: http_tool.c:163
int www2browser_relay(int bofd, int wofd, int btm, int wtm, int keep)
Definition: http_tool.c:1240
unsigned char ** buf
Definition: jpeg_tool.h:96
unsigned char unsigned long * len
Definition: jpeg_tool.h:96
プロトコル解析ライブラリ ヘッダ
Definition: buffer.h:35
Tiny XML ライブラリヘッダ