2008-04-24 01:42:53 +00:00
|
|
|
/*
|
2011-01-19 13:48:47 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2008-04-24 01:42:53 +00:00
|
|
|
*
|
2010-12-27 19:18:17 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
2008-04-24 01:42:53 +00:00
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2008-04-24 01:42:53 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*
|
2008-04-25 19:46:36 +00:00
|
|
|
* $Id$
|
2008-04-24 01:42:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TR_HTTP_H
|
|
|
|
#define TR_HTTP_H
|
|
|
|
|
2011-07-10 15:24:51 +00:00
|
|
|
#include <curl/curl.h>
|
|
|
|
|
2010-12-11 21:27:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-10-23 03:41:36 +00:00
|
|
|
struct tr_address;
|
2011-07-10 15:24:51 +00:00
|
|
|
struct tr_web_task;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_WEB_GET_CODE = CURLINFO_RESPONSE_CODE,
|
|
|
|
TR_WEB_GET_REDIRECTS = CURLINFO_REDIRECT_COUNT,
|
|
|
|
TR_WEB_GET_REAL_URL = CURLINFO_EFFECTIVE_URL
|
|
|
|
}
|
|
|
|
tr_web_task_info;
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2010-03-06 15:05:05 +00:00
|
|
|
void tr_webInit( tr_session * session );
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2010-03-06 15:05:05 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TR_WEB_CLOSE_WHEN_IDLE,
|
|
|
|
TR_WEB_CLOSE_NOW
|
|
|
|
}
|
|
|
|
tr_web_close_mode;
|
2008-04-25 19:46:36 +00:00
|
|
|
|
2010-03-06 15:05:05 +00:00
|
|
|
void tr_webClose( tr_session * session, tr_web_close_mode close_mode );
|
|
|
|
|
2008-12-14 11:21:11 +00:00
|
|
|
typedef void ( tr_web_done_func )( tr_session * session,
|
2011-03-22 15:19:54 +00:00
|
|
|
bool timeout_flag,
|
|
|
|
bool did_connect_flag,
|
2008-09-23 19:11:04 +00:00
|
|
|
long response_code,
|
2008-12-14 11:21:11 +00:00
|
|
|
const void * response,
|
2008-09-23 19:11:04 +00:00
|
|
|
size_t response_byte_count,
|
2008-12-14 11:21:11 +00:00
|
|
|
void * user_data );
|
2008-04-25 04:26:04 +00:00
|
|
|
|
|
|
|
const char * tr_webGetResponseStr( long response_code );
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2011-07-10 15:24:51 +00:00
|
|
|
struct tr_web_task * tr_webRun( tr_session * session,
|
|
|
|
const char * url,
|
|
|
|
const char * range,
|
|
|
|
const char * cookies,
|
|
|
|
tr_web_done_func done_func,
|
|
|
|
void * done_func_user_data );
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2009-11-11 01:03:06 +00:00
|
|
|
struct evbuffer;
|
|
|
|
|
2011-07-10 15:24:51 +00:00
|
|
|
struct tr_web_task * tr_webRunWithBuffer( tr_session * session,
|
|
|
|
const char * url,
|
|
|
|
const char * range,
|
|
|
|
const char * cookies,
|
|
|
|
tr_web_done_func done_func,
|
|
|
|
void * done_func_user_data,
|
|
|
|
struct evbuffer * buffer );
|
|
|
|
|
|
|
|
void tr_webGetTaskInfo( struct tr_web_task * task, tr_web_task_info info, void * dst );
|
2011-01-06 01:00:21 +00:00
|
|
|
|
2011-03-22 15:19:54 +00:00
|
|
|
void tr_http_escape( struct evbuffer *out, const char *str, int len, bool escape_slashes );
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2011-03-11 04:19:01 +00:00
|
|
|
void tr_http_escape_sha1( char * out, const uint8_t * sha1_digest );
|
|
|
|
|
2009-11-20 04:38:19 +00:00
|
|
|
char* tr_http_unescape( const char * str, int len );
|
|
|
|
|
2010-12-11 21:27:15 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-04-24 01:42:53 +00:00
|
|
|
#endif
|