Subversion Repositories Kolibri OS

Rev

Rev 5534 | Rev 5598 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4163 hidnplayr 1
//HTTP library
2
 
4165 hidnplayr 3
dword libHTTP = #alibHTTP;
4
char alibHTTP[23] = "/sys/lib/http.obj\0";
5
 
5576 pavelyakov 6
dword http_lib_init          = #aLib_init;
7
dword http_get               = #aHTTPget;
8
dword http_head              = #aHTTPhead;
9
dword http_post              = #aHTTPpost;
4235 leency 10
dword http_find_header_field = #aFHF;
5576 pavelyakov 11
dword http_send              = #aHTTPsend;
12
dword http_receive           = #aHTTPreceive;
13
dword http_disconnect        = #aHTTPdisconnect;
14
dword http_free              = #aHTTPfree;
15
dword uri_escape             = #aURIescape;
16
dword uri_unescape           = #aURIunescape;
4163 hidnplayr 17
$DD 2 dup 0
18
 
19
char aLib_init[9]              = "lib_init\0";
20
char aHTTPget[4]               = "get\0";
4235 leency 21
char aHTTPhead[5]              = "head\0";
22
char aHTTPpost[5]              = "post\0";
23
char aFHF[18]                  = "find_header_field\0";
5534 hidnplayr 24
char aHTTPsend[5]              = "send\0";
25
char aHTTPreceive[8]           = "receive\0";
26
char aHTTPdisconnect[11]       = "disconnect\0";
4235 leency 27
char aHTTPfree[5]              = "free\0";
28
char aURIescape[7]             = "escape\0";
29
char aURIunescape[9]           = "unescape\0";
4163 hidnplayr 30
 
5534 hidnplayr 31
// status flags
4163 hidnplayr 32
#define FLAG_HTTP11             1 << 0
33
#define FLAG_GOT_HEADER         1 << 1
4536 leency 34
#define FLAG_GOT_ALL_DATA       1 << 2
4163 hidnplayr 35
#define FLAG_CONTENT_LENGTH     1 << 3
36
#define FLAG_CHUNKED            1 << 4
4235 leency 37
#define FLAG_CONNECTED          1 << 5
4163 hidnplayr 38
 
5534 hidnplayr 39
// user flags
40
#define FLAG_KEEPALIVE          1 << 8
41
#define FLAG_MULTIBUFF			1 << 9
42
 
43
// error flags
4163 hidnplayr 44
#define FLAG_INVALID_HEADER     1 << 16
45
#define FLAG_NO_RAM             1 << 17
46
#define FLAG_SOCKET_ERROR       1 << 18
4235 leency 47
#define FLAG_TIMEOUT_ERROR      1 << 19
4536 leency 48
#define FLAG_TRANSFER_FAILED    1 << 20
4163 hidnplayr 49
 
50
struct  http_msg{
51
        dword   socket;
52
        dword   flags;
53
        dword   write_ptr;
54
        dword   buffer_length;
55
        dword   chunk_ptr;
4235 leency 56
        dword   timestamp;
4163 hidnplayr 57
        dword   status;
58
        dword   header_length;
4536 leency 59
		dword	content_ptr;
4163 hidnplayr 60
        dword   content_length;
4168 hidnplayr 61
        dword   content_received;
4536 leency 62
        char    http_header;
5576 pavelyakov 63
};
64
 
65
:dword file_get_contents(dword url,...)
66
{
67
	http_get(url,FLAG_HTTP11,"");
68
}