1 | /* |
---|
2 | * This file Copyright (C) Mnemosyne LLC |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2 (b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: web.h 14070 2013-04-13 20:25:28Z jordan $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef TR_HTTP_H |
---|
14 | #define TR_HTTP_H |
---|
15 | |
---|
16 | #include <curl/curl.h> |
---|
17 | |
---|
18 | #ifdef __cplusplus |
---|
19 | extern "C" { |
---|
20 | #endif |
---|
21 | |
---|
22 | struct tr_address; |
---|
23 | struct tr_web_task; |
---|
24 | |
---|
25 | typedef enum |
---|
26 | { |
---|
27 | TR_WEB_GET_CODE = CURLINFO_RESPONSE_CODE, |
---|
28 | TR_WEB_GET_REDIRECTS = CURLINFO_REDIRECT_COUNT, |
---|
29 | TR_WEB_GET_REAL_URL = CURLINFO_EFFECTIVE_URL |
---|
30 | } |
---|
31 | tr_web_task_info; |
---|
32 | |
---|
33 | typedef enum |
---|
34 | { |
---|
35 | TR_WEB_CLOSE_WHEN_IDLE, |
---|
36 | TR_WEB_CLOSE_NOW |
---|
37 | } |
---|
38 | tr_web_close_mode; |
---|
39 | |
---|
40 | void tr_webClose (tr_session * session, tr_web_close_mode close_mode); |
---|
41 | |
---|
42 | typedef void (tr_web_done_func)(tr_session * session, |
---|
43 | bool timeout_flag, |
---|
44 | bool did_connect_flag, |
---|
45 | long response_code, |
---|
46 | const void * response, |
---|
47 | size_t response_byte_count, |
---|
48 | void * user_data); |
---|
49 | |
---|
50 | const char * tr_webGetResponseStr (long response_code); |
---|
51 | |
---|
52 | struct tr_web_task * tr_webRun (tr_session * session, |
---|
53 | const char * url, |
---|
54 | tr_web_done_func done_func, |
---|
55 | void * done_func_user_data); |
---|
56 | |
---|
57 | struct tr_web_task * tr_webRunWithCookies (tr_session * session, |
---|
58 | const char * url, |
---|
59 | const char * cookies, |
---|
60 | tr_web_done_func done_func, |
---|
61 | void * done_func_user_data); |
---|
62 | |
---|
63 | struct evbuffer; |
---|
64 | |
---|
65 | struct tr_web_task * tr_webRunWebseed (tr_torrent * tor, |
---|
66 | const char * url, |
---|
67 | const char * range, |
---|
68 | tr_web_done_func done_func, |
---|
69 | void * done_func_user_data, |
---|
70 | struct evbuffer * buffer); |
---|
71 | |
---|
72 | void tr_webGetTaskInfo (struct tr_web_task * task, tr_web_task_info info, void * dst); |
---|
73 | |
---|
74 | void tr_http_escape (struct evbuffer *out, const char *str, int len, bool escape_slashes); |
---|
75 | |
---|
76 | void tr_http_escape_sha1 (char * out, const uint8_t * sha1_digest); |
---|
77 | |
---|
78 | char* tr_http_unescape (const char * str, int len); |
---|
79 | |
---|
80 | #ifdef __cplusplus |
---|
81 | } |
---|
82 | #endif |
---|
83 | |
---|
84 | #endif |
---|