@@ -144,6 +144,23 @@ class Transport(TransportMixIn, XMLTransport):
144
144
145
145
class SafeTransport (TransportMixIn , XMLSafeTransport ):
146
146
pass
147
+
148
+ from httplib import HTTP , HTTPConnection
149
+ from socket import socket , AF_UNIX , SOCK_STREAM
150
+ class UnixHTTPConnection (HTTPConnection ):
151
+ def connect (self ):
152
+ self .sock = socket (AF_UNIX , SOCK_STREAM )
153
+ self .sock .connect (self .host )
154
+
155
+ class UnixHTTP (HTTP ):
156
+ _connection_class = UnixHTTPConnection
157
+
158
+ class UnixTransport (TransportMixIn , XMLTransport ):
159
+ def make_connection (self , host ):
160
+ import httplib
161
+ host , extra_headers , x509 = self .get_host_info (host )
162
+ return UnixHTTP (host )
163
+
147
164
148
165
class ServerProxy (XMLServerProxy ):
149
166
"""
@@ -158,15 +175,21 @@ def __init__(self, uri, transport=None, encoding=None,
158
175
version = config .version
159
176
self .__version = version
160
177
schema , uri = urllib .splittype (uri )
161
- if schema not in ('http' , 'https' ):
178
+ if schema not in ('http' , 'https' , 'unix' ):
162
179
raise IOError ('Unsupported JSON-RPC protocol.' )
163
- self .__host , self .__handler = urllib .splithost (uri )
164
- if not self .__handler :
165
- # Not sure if this is in the JSON spec?
166
- #self.__handler = '/'
167
- self .__handler == '/'
180
+ if schema == 'unix' :
181
+ self .__host = uri
182
+ self .__handler = '/'
183
+ else :
184
+ self .__host , self .__handler = urllib .splithost (uri )
185
+ if not self .__handler :
186
+ # Not sure if this is in the JSON spec?
187
+ #self.__handler = '/'
188
+ self .__handler == '/'
168
189
if transport is None :
169
- if schema == 'https' :
190
+ if schema == 'unix' :
191
+ transport = UnixTransport ()
192
+ elif schema == 'https' :
170
193
transport = SafeTransport ()
171
194
else :
172
195
transport = Transport ()
0 commit comments