Exemplo n.º 1
0
	def remove(self, key):
		if isinstance(key, str): key = key.encode("utf8")
		key = "/" + urllib_parse_quote(key)
		self.ua.request("DELETE", key)
		res = self.ua.getresponse()
		body = res.read()
		return res.status == 204
Exemplo n.º 2
0
	def get(self, key):
		if key==None or key=="" or key==b"":
			return None
		else:
			if isinstance(key, str): key = key.encode("utf8")
			key = "/" + urllib_parse_quote(key)

			self.ua.request("GET", key)
			res = self.ua.getresponse()
			body = res.read()
			if res.status != 200:
				return None
			else:
				return body
Exemplo n.º 3
0
	def set(self, key, value, xt = None):
		if key==None or key=='' or key==b'' or value==None or value=='' or value==b'':
			return None
		else:
			if isinstance(key, str): key = key.encode("utf8")
			if isinstance(value, str): value = value.encode("utf8")
			key = "/" + urllib_parse_quote(key)

			headers = {}
			if xt != None:
				xt = int(time.time()) + xt
				headers["X-Kt-Xt"] = str(xt)

			self.ua.request("PUT", key, value, headers)
			res = self.ua.getresponse()
			body = res.read()
			return res.status == 201