- add new Source for Request-data
[enigma2-plugins.git] / webinterface / src / WebComponents / Sources / RequestData.py
1 from Components.Sources.Source import Source
2
3 class RequestData(Source):
4         """
5                 a source for requestinformations like the adress that the client requested to reache the box
6         """
7         HOST = 0
8         PORT = 1
9         METHOD = 2
10         PATH = 3
11         REMOTEADRESS = 4
12         REMOTEPORT = 5
13         REMOTETYPE = 6
14         URI = 7
15         
16         def __init__(self,request, what = None):
17                 Source.__init__(self)
18                 self.request = request
19                 self.what = what
20
21         def handleCommand(self, cmd):
22                 pass
23                 
24         def getHTML(self, id):
25                 if self.what is self.HOST:
26                         return self.request.host
27                 elif self.what is self.PORT:
28                         return self.request.port
29                 elif self.what is self.METHOD:
30                         return self.request.method
31                 elif self.what is self.PATH:
32                         return self.request.path
33                 elif self.what is self.REMOTEADRESS:
34                         return self.request.remoteAddr.host
35                 elif self.what is self.REMOTEPORT:
36                         return self.request.remoteAddr.port
37                 elif self.what is self.REMOTETYPE:
38                         return self.request.remoteAddr.type
39                 elif self.what is self.URI:
40                         return self.request.uri
41                 else:
42                         return "N/A"