19
19
from bzrlib.transport import Transport, register_transport
20
20
from bzrlib.errors import (TransportNotPossible, NoSuchFile,
21
NonRelativePath, TransportError, ConnectionError)
21
TransportError, ConnectionError)
23
23
from cStringIO import StringIO
24
24
import urllib, urllib2
154
151
cleaner if we just do an http HEAD request, and parse
158
f = get_url(self.abspath(relpath))
156
path = self.abspath(relpath)
159
158
# Without the read and then close()
160
159
# we tend to have busy sockets.
164
163
except urllib2.URLError, e:
164
mutter('url error code: %s for has url: %r', e.code, path)
165
165
if e.code == 404:
168
168
except IOError, e:
169
mutter('io error: %s %s for has url: %r',
170
e.errno, errno.errorcode.get(e.errno), path)
169
171
if e.errno == errno.ENOENT:
171
raise HttpTransportError(orig_error=e)
173
raise TransportError(orig_error=e)
173
175
def get(self, relpath, decode=False):
174
176
"""Get the file at the given relative path.
176
178
:param relpath: The relative path to the file
179
return get_url(self.abspath(relpath))
182
path = self.abspath(relpath)
180
184
except urllib2.HTTPError, e:
185
mutter('url error code: %s for has url: %r', e.code, path)
181
186
if e.code == 404:
182
raise NoSuchFile(msg = "Error retrieving %s: %s"
183
% (self.abspath(relpath), str(e)),
187
raise NoSuchFile(path, extra=e)
186
189
except (BzrError, IOError), e:
190
if hasattr(e, 'errno'):
191
mutter('io error: %s %s for has url: %r',
192
e.errno, errno.errorcode.get(e.errno), path)
193
if e.errno == errno.ENOENT:
194
raise NoSuchFile(path, extra=e)
187
195
raise ConnectionError(msg = "Error retrieving %s: %s"
188
196
% (self.abspath(relpath), str(e)),