[Tarantool-patches] [PATCH v1 1/4] test: fix app-tap/http_client.test.lua

Sergey Bronnikov sergeyb at tarantool.org
Thu Jan 14 12:50:50 MSK 2021


Thanks for review!

On 14.01.2021 11:47, Leonid Vasiliev wrote:
> Hi! Thank you for the patch.
>
> Generally LGTM. See some comments below:
>
> On 13.01.2021 11:48, sergeyb at tarantool.org wrote:
>> From: Sergey Bronnikov <estetus at gmail.com>
>>
>> Pass http body as byte string and define string literals correctly.
>>
>> Part of #5538
>
> AFAIU, if the task has been closed, new patches corresponding with the
> task are marked as "Follows up".
>
Updated commit messages.
>> ---
>>   test/app-tap/httpd.py | 20 ++++++++++----------
>>   1 file changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/test/app-tap/httpd.py b/test/app-tap/httpd.py
>> index a2dee1b83..62435e91a 100755
>> --- a/test/app-tap/httpd.py
>> +++ b/test/app-tap/httpd.py
>> @@ -7,24 +7,24 @@ from gevent import spawn, sleep, socket
>>   def absent():
>>       code = "500 Server Error"
>>       headers = [("Content-Type", "application/json")]
>> -    body = ["No such method"]
>> +    body = [b'No such method']
>>       return code, body, headers
>>     def hello():
>>       code = "200 OK"
>> -    body = ["hello world"]
>> +    body = [b'hello world']
>>       headers = [("Content-Type", "application/json")]
>>       return code, body, headers
>>     def hello1():
>>       code = "200 OK"
>> -    body = [b"abc"]
>> +    body = [b'abc']
>>       headers = [("Content-Type", "application/json")]
>>       return code, body, headers
>>     def headers():
>>       code = "200 OK"
>> -    body = [b"cookies"]
>> +    body = [b'cookies']
>>       headers = [("Content-Type", "application/json"),
>>                  ("Content-Type", "application/yaml"),
>>                  ("Set-Cookie", "likes=cheese; Expires=Wed, 21 Oct 
>> 2015 07:28:00 GMT; Secure; HttpOnly"),
>> @@ -41,13 +41,13 @@ def headers():
>>   def long_query():
>>       sleep(0.005)
>>       code = "200 OK"
>> -    body = [b"abc"]
>> +    body = [b'abc']
>>       headers = [("Content-Type", "application/json")]
>>       return code, body, headers
>>     def redirect():
>>       code = "302 Found"
>> -    body = ["redirecting"]
>> +    body = [b'redirecting']
>>       headers = [("Location", "/")]
>>       return code, body, headers
>>   @@ -63,7 +63,7 @@ paths = {
>>   def read_handle(env, response):
>>       code = "404 Not Found"
>>       headers = []
>> -    body = ["Not Found"]
>> +    body = [b'Not Found']
>>       if env["PATH_INFO"] in paths:
>>           code, body, headers = paths[env["PATH_INFO"]]()
>>       for key,value in iter(env.items()):
>> @@ -76,7 +76,7 @@ def post_handle(env, response):
>>       code = "200 OK"
>>       body = [env["wsgi.input"].read()]
>>       headers = []
>> -    for key,value in env.iteritems():
>> +    for key,value in iter(env.items()):
>
> This change is not about "Pass http body as byte string and define 
> string literals correctly." Please edit the commit message or move 
> this change to a separate commit.
>
commit 00c194f09b230cd01f38ed7e08e5fcc7e2d56928
Author: Sergey Bronnikov <sergeyb at tarantool.org>
Date:   Mon Dec 28 15:15:41 2020 +0300

     test: fix app-tap/http_client.test.lua

     Pass http body as byte string, define string literals correctly
     and make items() iterable.

     Follows up #5538

>>           if "HTTP_" in key:
>>               headers.append((key[5:].lower(), value))
>>       response(code, headers)
>> @@ -84,8 +84,8 @@ def post_handle(env, response):
>>     def other_handle(env, response, method, code):
>>       headers = [("Content-Type", "text/plain"), ("method", method)]
>> -    body = [method]
>> -    for key,value in env.iteritems():
>> +    body = [method.encode('utf-8')]
>
>> +    for key,value in iter(env.items()):
>
> This change is not about "Pass http body as byte string and define 
> string literals correctly." Please edit the commit message or move 
> this change to a separate commit.
>
>>           if "HTTP_" in key:
>>               headers.append((key[5:].lower(), value))
>>       response(code, headers)
>>


More information about the Tarantool-patches mailing list