Exemple #1
0
	def _get(self, querystring):
		res = fckit.http_request(
			hostname = "localhost",
			port = PORT,
			method = "GET",
			headers = {"Accept": "application/json"},
			path = "/hello%s" % querystring)
		self.assertEqual(res.status, 200)
		return json.loads(res.read())
Exemple #2
0
 def _get(self, querystring):
     res = fckit.http_request(
         hostname="localhost",
         port=PORT,
         method="GET",
         headers={"Accept": "application/json"},
         path="/hello%s" % querystring,
     )
     self.assertEqual(res.status, 200)
     return json.loads(res.read())
Exemple #3
0
	def _get(self, querystring = None):
		res = fckit.http_request(
			hostname = "localhost",
			port = PROXYPORT or PORT,
			method = "GET",
			headers = {"Accept": "application/json"},
			path = "%s%s%s" % (("http://localhost:%i" % PORT) if PROXYPORT else "", PATH, querystring or ""))  
		self.assertIn(res.status, (200, 206))
		if res.status == 206:
			content_range = res.getheader("Content-Range")
			lbound, ubound, count = map(int, re.match(r"(\d+)-(\d+)/(\d+)", content_range).groups())
			self.assertLessEqual(lbound, ubound)
			self.assertLessEqual(ubound, count)
			accept_range = res.getheader("Accept-Range")
			name, maxcount = re.match(r"(\w+) (\d+)", accept_range).groups()
			maxcount = int(maxcount)
		return json.loads(res.read())