From e588785dd13ae5f67be8071aab66d1ae87b64265 Mon Sep 17 00:00:00 2001 From: pancho horrillo Date: Fri, 10 May 2019 16:37:49 +0200 Subject: [PATCH] poc/kapow: fix function name --- poc/kapow | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/poc/kapow b/poc/kapow index e2840ba..c2183c0 100755 --- a/poc/kapow +++ b/poc/kapow @@ -59,8 +59,8 @@ class Connection: """Get the content of the field `key`.""" res = urlparse(key) - def nrd(n): - """Return the nrd element in a path.""" + def nth(n): + """Return the nth element in a path.""" return res.path.split('/')[n] if res.path == 'request/method': @@ -70,18 +70,18 @@ class Connection: elif res.path == 'request/path': return self.request.path.encode('utf-8') elif res.path.startswith('request/match/'): - return self.request.match_info[nrd(2)].encode('utf-8') + return self.request.match_info[nth(2)].encode('utf-8') elif res.path.startswith('request/param/'): - return self.request.rel_url.query[nrd(2)].encode('utf-8') + return self.request.rel_url.query[nth(2)].encode('utf-8') elif res.path.startswith('request/header/'): - return self.request.headers[nrd(2)].encode('utf-8') + return self.request.headers[nth(2)].encode('utf-8') elif res.path.startswith('request/cookie/'): - return self.request.cookies[nrd(2)].encode('utf-8') + return self.request.cookies[nth(2)].encode('utf-8') elif res.path.startswith('request/form/'): - return (await self.request.post())[nrd(2)].encode('utf-8') + return (await self.request.post())[nth(2)].encode('utf-8') elif res.path.startswith('request/file/'): - name = nrd(2) - content = nrd(3) # filename / content + name = nth(2) + content = nth(3) # filename / content field = (await self.request.post())[name] if content == 'filename': try: @@ -102,7 +102,7 @@ class Connection: """Set the field `key` with the value in `content`.""" res = urlparse(key) - def nrd(n): + def nth(n): return res.path.split('/')[n] if res.path == 'response/status': @@ -111,10 +111,10 @@ class Connection: self._body.write(await content.read()) elif res.path.startswith('response/header/'): clean = (await content.read()).rstrip(b'\n').decode('utf-8') - self._headers[nrd(2)] = clean + self._headers[nth(2)] = clean elif res.path.startswith('response/cookie/'): clean = (await content.read()).rstrip(b'\n').decode('utf-8') - self._cookies[nrd(2)] = clean + self._cookies[nth(2)] = clean elif res.path == 'response/stream': if self._stream is None: self._stream = web.StreamResponse(status=self._status,