2
<title>Http handler</title>
5
<section id="introduction"><title>Introduction</title>
8
LibTorrent depends on the client to handle http downloads, thus the
9
library does not have a dependency on any specific http library. The
10
library provides a base class named torrent::Http with virtual member
11
functions that the client must implement, and a sigc++ slot which must
12
be set to create an instance of the derived torrent::Http class when
17
The torrent::Http class and the factory slot related functions can be
18
found in the header "torrent/http.h". The http handler should have
19
reasonable connection timeouts, be non-blocking and not do reconnects
26
<section id="factory"><title>Factory Slot</title>
29
The client registers the desired factory slot with the static
30
torrent::Http::set_factory member function. Using sigc++ the client
31
may bind values to the arguments of their function to avoid depending
32
on globals. The factory slot must return a pointer to a new instance
33
with the base type torrent::Http, and the caller takes responsibility
34
of deleting the object. (Note: consider making the cleanup a slot)
40
<section id="stream"><title>Output Stream</title>
43
The data downloaded by the http handler is to be written to
44
torrent::Http::m_stream which is a pointer to an std::iostream. The
45
http handler must not change any of the flags on the stream.
51
<section id="start"><title>Start</title>
54
Http::start is called by the library when it wishes to initiate a http
55
download. Your Http derived class must implement this function. It
56
must be non-blocking and thread-safe. This means that if a seperate
57
thread is used for downloading then it must not emit any signal while
58
the main thread is inside the library.
62
<section id="close"><title>close</title>
65
Http::close is used bu the library to stop and close a download. No
66
signals may be emited after this. Http::m_data should not be
67
cleared. The library may clear the Http::m_data pointer after this.
71
<section id="signals"><title>Signals</title>
74
There are two mutually exclusive signals that are called when the
75
download has stopped. The signal torrent::Http::m_signalDone is called
76
if the download was successful and torrent::Http::m_stream contains
77
the complete data. Or if the download was unsuccessful for some
78
reason, then torrent::Http::m_signalFailed is called with an error
b'\\ No newline at end of file'