From 1e8ab38b92387ba1fb265a5d757a6ac15820e5b1 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sun, 13 Oct 2013 20:36:51 +0000 Subject: Use HEAD request to check object existance --- 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 -- cgit v0.9.1