1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import time
19
20
21
22 INTERNAL_ERROR = 500
23 NOT_IMPLEMENTED = 501
24 SERVER_UNAVAILABLE = 503
25 RANGE_NOT_SATISFIABLE = 416
26 STREAM_NOTFOUND = 404
27 STREAM_FORBIDDEN = 403
28
29
30 SERVER_DISCONNECTED = 502
31 SERVER_TIMEOUT = 504
32
33
34 STREAM_NOT_MODIFIED = 304
35 STREAM_MODIFIED = 412
36
37
39 """
40 Interface of the stream consumer object.
41 No need to inherit from this class,
42 it's here just for documentation.
43 """
44
47
50
53
54 - def onInfo(self, getter, info):
56
57 - def onData(self, getter, data):
59
62
63
65 """
66 Base stream's information container.
67 No need to inherit from this class,
68 it's here just for documentation.
69 """
70 expires = None
71 mtime = None
72 length = 0
73 start = 0
74 size = 0
75
76
78
80 self.adress = None
81 self.protocol = "http"
82
83
85 """
86 Gives a unique string identifier for an instance.
87 Used in the log to trace instances.
88 """
89 result = id(obj)
90 if result < 0:
91 result += 1L << 32
92 if result < 0:
93
94 result -= 1L << 32
95 result += 1L << 64
96 assert result > 0, "Address space fatter than 64 bits"
97 result = (result << 16) + (int(time.time()) & 0xFFFF)
98 return hex(result)[2:]
99