Rev 6001 | Rev 6887 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6001 | Rev 6005 | ||
---|---|---|---|
1 | //HTTP library |
- | |
2 | #ifndef INCLUDE_LIBHTTP_H |
1 | #ifndef INCLUDE_LIBHTTP_H |
3 | #define INCLUDE_LIBHTTP_H |
2 | #define INCLUDE_LIBHTTP_H |
4 | #print "[include |
3 | #print "[include |
5 | 4 | ||
6 | #ifndef INCLUDE_KOLIBRI_H |
5 | #ifndef INCLUDE_KOLIBRI_H |
7 | #include "../lib/kolibri.h" |
6 | #include "../lib/kolibri.h" |
8 | #endif |
7 | #endif |
9 | 8 | ||
10 | #ifndef INCLUDE_DLL_H |
9 | #ifndef INCLUDE_DLL_H |
11 | #include "../lib/dll.h" |
10 | #include "../lib/dll.h" |
12 | #endif |
11 | #endif |
13 | - | ||
14 | dword NOT_INIT_LIBHTTP = true; |
12 | |
15 | dword libHTTP = #alibHTTP; |
13 | dword libHTTP = #alibHTTP; |
16 | char alibHTTP[23] = "/sys/lib/http.obj\0"; |
14 | char alibHTTP[] = "/sys/lib/http.obj"; |
17 | 15 | ||
18 | dword http_lib_init = #aLib_init; |
16 | dword http_lib_init = #aLib_init; |
19 | dword http_get = #aHTTPget; |
17 | dword http_get = #aHTTPget; |
20 | dword http_head = #aHTTPhead; |
18 | dword http_head = #aHTTPhead; |
21 | dword http_post = #aHTTPpost; |
19 | dword http_post = #aHTTPpost; |
22 | dword http_find_header_field = #aFHF; |
20 | dword http_find_header_field = #aFHF; |
23 | dword http_send = #aHTTPsend; |
21 | dword http_send = #aHTTPsend; |
24 | dword http_receive = #aHTTPreceive; |
22 | dword http_receive = #aHTTPreceive; |
25 | dword http_disconnect = #aHTTPdisconnect; |
23 | dword http_disconnect = #aHTTPdisconnect; |
26 | dword http_free = #aHTTPfree; |
24 | dword http_free = #aHTTPfree; |
27 | dword uri_escape = #aURIescape; |
25 | dword uri_escape = #aURIescape; |
28 | dword uri_unescape = #aURIunescape; |
26 | dword uri_unescape = #aURIunescape; |
29 | $DD 2 dup 0 |
27 | $DD 2 dup 0 |
30 | 28 | ||
31 | char aLib_init[9] = "lib_init\0"; |
29 | char aLib_init[] = "lib_init"; |
32 | char aHTTPget[4] = "get\0"; |
30 | char aHTTPget[] = "get"; |
33 | char aHTTPhead[5] = "head\0"; |
31 | char aHTTPhead[] = "head"; |
34 | char aHTTPpost[5] = "post\0"; |
32 | char aHTTPpost[] = "post"; |
35 | char aFHF[18] = "find_header_field\0"; |
33 | char aFHF[] = "find_header_field"; |
36 | char aHTTPsend[5] = "send\0"; |
34 | char aHTTPsend[] = "send"; |
37 | char aHTTPreceive[8] = "receive\0"; |
35 | char aHTTPreceive[] = "receive"; |
38 | char aHTTPdisconnect[11] = "disconnect\0"; |
36 | char aHTTPdisconnect[] = "disconnect"; |
39 | char aHTTPfree[5] = "free\0"; |
37 | char aHTTPfree[] = "free"; |
40 | char aURIescape[7] = "escape\0"; |
38 | char aURIescape[] = "escape"; |
41 | char aURIunescape[9] = "unescape\0"; |
39 | char aURIunescape[] = "unescape"; |
42 | 40 | ||
43 | // status flags |
41 | // status flags |
44 | #define FLAG_HTTP11 1 << 0 |
42 | #define FLAG_HTTP11 1 << 0 |
45 | #define FLAG_GOT_HEADER 1 << 1 |
43 | #define FLAG_GOT_HEADER 1 << 1 |
46 | #define FLAG_GOT_ALL_DATA 1 << 2 |
44 | #define FLAG_GOT_ALL_DATA 1 << 2 |
47 | #define FLAG_CONTENT_LENGTH 1 << 3 |
45 | #define FLAG_CONTENT_LENGTH 1 << 3 |
48 | #define FLAG_CHUNKED 1 << 4 |
46 | #define FLAG_CHUNKED 1 << 4 |
49 | #define FLAG_CONNECTED 1 << 5 |
47 | #define FLAG_CONNECTED 1 << 5 |
50 | 48 | ||
51 | // user flags |
49 | // user flags |
52 | #define FLAG_KEEPALIVE 1 << 8 |
50 | #define FLAG_KEEPALIVE 1 << 8 |
53 | #define FLAG_MULTIBUFF 1 << 9 |
51 | #define FLAG_MULTIBUFF 1 << 9 |
54 | 52 | ||
55 | // error flags |
53 | // error flags |
56 | #define FLAG_INVALID_HEADER 1 << 16 |
54 | #define FLAG_INVALID_HEADER 1 << 16 |
57 | #define FLAG_NO_RAM 1 << 17 |
55 | #define FLAG_NO_RAM 1 << 17 |
58 | #define FLAG_SOCKET_ERROR 1 << 18 |
56 | #define FLAG_SOCKET_ERROR 1 << 18 |
59 | #define FLAG_TIMEOUT_ERROR 1 << 19 |
57 | #define FLAG_TIMEOUT_ERROR 1 << 19 |
60 | #define FLAG_TRANSFER_FAILED 1 << 20 |
58 | #define FLAG_TRANSFER_FAILED 1 << 20 |
61 | 59 | ||
62 | struct http_msg{ |
60 | struct http_msg{ |
63 | dword socket; |
61 | dword socket; |
64 | dword flags; |
62 | dword flags; |
65 | dword write_ptr; |
63 | dword write_ptr; |
66 | dword buffer_length; |
64 | dword buffer_length; |
67 | dword chunk_ptr; |
65 | dword chunk_ptr; |
68 | dword timestamp; |
66 | dword timestamp; |
69 | dword status; |
67 | dword status; |
70 | dword header_length; |
68 | dword header_length; |
71 | dword content_ptr; |
69 | dword content_ptr; |
72 | dword content_length; |
70 | dword content_length; |
73 | dword content_received; |
71 | dword content_received; |
74 | char http_header; |
72 | char http_header; |
75 | }; |
73 | }; |
76 | - | ||
77 | :dword file_get_contents(dword url,...) |
- | |
78 | { |
- | |
79 | http_get(url,FLAG_HTTP11,""); |
- | |
80 | } |
74 | |
81 | 75 | ||
82 | #endif><>><>><>><>><>><>><>><>><>><>><>><>><> |
76 | #endif><>><>><>><>><>><>><>><>><>><>><>><>><> |
- | 77 | ||
- | 78 | #ifndef> |