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