2008-04-24 01:42:53 +00:00
|
|
|
/*
|
2014-01-19 01:09:44 +00:00
|
|
|
* This file Copyright (C) 2008-2014 Mnemosyne LLC
|
2008-04-24 01:42:53 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2008-04-24 01:42:53 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2021-10-16 13:20:04 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <string_view>
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
#include "tr-macros.h"
|
|
|
|
|
2009-10-23 03:41:36 +00:00
|
|
|
struct tr_address;
|
2011-07-10 15:24:51 +00:00
|
|
|
struct tr_web_task;
|
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
enum tr_web_close_mode
|
2010-03-06 15:05:05 +00:00
|
|
|
{
|
|
|
|
TR_WEB_CLOSE_WHEN_IDLE,
|
|
|
|
TR_WEB_CLOSE_NOW
|
2021-10-06 14:26:07 +00:00
|
|
|
};
|
2008-04-25 19:46:36 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_webClose(tr_session* session, tr_web_close_mode close_mode);
|
2010-03-06 15:05:05 +00:00
|
|
|
|
2021-10-06 14:26:07 +00:00
|
|
|
using tr_web_done_func = void (*)(
|
2021-08-15 09:41:48 +00:00
|
|
|
tr_session* session,
|
|
|
|
bool did_connect_flag,
|
|
|
|
bool timeout_flag,
|
|
|
|
long response_code,
|
|
|
|
void const* response,
|
|
|
|
size_t response_byte_count,
|
|
|
|
void* user_data);
|
2008-04-25 04:26:04 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_webGetResponseStr(long response_code);
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
struct tr_web_task* tr_webRun(tr_session* session, char const* url, tr_web_done_func done_func, void* done_func_user_data);
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
struct tr_web_task* tr_webRunWithCookies(
|
|
|
|
tr_session* session,
|
|
|
|
char const* url,
|
|
|
|
char const* cookies,
|
|
|
|
tr_web_done_func done_func,
|
2017-04-19 12:04:45 +00:00
|
|
|
void* done_func_user_data);
|
2013-04-13 20:25:28 +00:00
|
|
|
|
2009-11-11 01:03:06 +00:00
|
|
|
struct evbuffer;
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
struct tr_web_task* tr_webRunWebseed(
|
|
|
|
tr_torrent* tor,
|
|
|
|
char const* url,
|
|
|
|
char const* range,
|
|
|
|
tr_web_done_func done_func,
|
|
|
|
void* done_func_user_data,
|
|
|
|
struct evbuffer* buffer);
|
2011-07-10 15:24:51 +00:00
|
|
|
|
2020-08-27 23:41:26 +00:00
|
|
|
long tr_webGetTaskResponseCode(struct tr_web_task* task);
|
|
|
|
|
|
|
|
char const* tr_webGetTaskRealUrl(struct tr_web_task* task);
|
2011-01-06 01:00:21 +00:00
|
|
|
|
2021-10-16 13:20:04 +00:00
|
|
|
void tr_http_escape(struct evbuffer* out, std::string_view str, bool escape_reserved);
|
2008-04-24 01:42:53 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_http_escape_sha1(char* out, uint8_t const* sha1_digest);
|
2011-03-11 04:19:01 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
char* tr_http_unescape(char const* str, size_t len);
|