diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2013-10-13 20:36:51 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2013-10-13 20:36:51 (GMT) |
commit | 1e8ab38b92387ba1fb265a5d757a6ac15820e5b1 (patch) | |
tree | a71d8b82dabd9ae634474408059fb7c4ec1f8a60 | |
parent | 0b6e646eaa79ccbd877d6e6f8ef5f3d2aea204e5 (diff) |
Use HEAD request to check object existance
-rw-r--r-- | sugar_network/toolkit/http.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/sugar_network/toolkit/http.py b/sugar_network/toolkit/http.py index 859d7e4..2780c1b 100644 --- a/sugar_network/toolkit/http.py +++ b/sugar_network/toolkit/http.py @@ -101,11 +101,6 @@ class GatewayTimeout(Status): status_code = 504 -def download(url, dst_path=None): - # TODO (?) Reuse HTTP session - return Connection().download(url, dst_path) - - class Connection(object): _Session = None @@ -134,8 +129,8 @@ class Connection(object): self._session.close() def exists(self, path): - reply = self.request('GET', path, allowed=[404]) - return reply.status_code != 404 + reply = self.request('HEAD', path, allowed=[NotFound.status_code]) + return reply.status_code != NotFound.status_code def head(self, path_=None, **kwargs): from sugar_network.toolkit.router import Request, Response |