1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 Contains transport interface (classes).
19 """
20
21
23 - def __init__(self, reason, httpcode, fp=None):
24 Exception.__init__(self, reason)
25 self.httpcode = httpcode
26 self.fp = fp
27
29 """
30 A transport request
31 @ivar url: The url for the request.
32 @type url: str
33 @ivar message: The message to be sent in a POST request.
34 @type message: str
35 @ivar headers: The http headers to be used for the request.
36 @type headers: dict
37 """
38
40 """
41 @param url: The url for the request.
42 @type url: str
43 @param message: The (optional) message to be send in the request.
44 @type message: str
45 """
46 self.url = url
47 self.headers = {}
48 self.message = message
49
51 s = []
52 s.append('URL:%s' % self.url)
53 s.append('HEADERS: %s' % self.headers)
54 s.append('MESSAGE:')
55 s.append(self.message)
56 return '\n'.join(s)
57
58
60 """
61 A transport reply
62 @ivar code: The http code returned.
63 @type code: int
64 @ivar message: The message to be sent in a POST request.
65 @type message: str
66 @ivar headers: The http headers to be used for the request.
67 @type headers: dict
68 """
69
70 - def __init__(self, code, headers, message):
71 """
72 @param code: The http code returned.
73 @type code: int
74 @param headers: The http returned headers.
75 @type headers: dict
76 @param message: The (optional) reply message received.
77 @type message: str
78 """
79 self.code = code
80 self.headers = headers
81 self.message = message
82
84 s = []
85 s.append('CODE: %s' % self.code)
86 s.append('HEADERS: %s' % self.headers)
87 s.append('MESSAGE:')
88 s.append(self.message)
89 return '\n'.join(s)
90
91
93 """
94 The transport I{interface}.
95 """
96
104
105 - def open(self, request):
106 """
107 Open the url in the specified request.
108 @param request: A transport request.
109 @type request: L{Request}
110 @return: An input stream.
111 @rtype: stream
112 @raise TransportError: On all transport errors.
113 """
114 raise Exception('not-implemented')
115
116 - def send(self, request):
117 """
118 Send soap message. Implementations are expected to handle:
119 - proxies
120 - I{http} headers
121 - cookies
122 - sending message
123 - brokering exceptions into L{TransportError}
124 @param request: A transport request.
125 @type request: L{Request}
126 @return: The reply
127 @rtype: L{Reply}
128 @raise TransportError: On all transport errors.
129 """
130 raise Exception('not-implemented')
131