[tarantool-patches] Re: [PATCH] httpc: add checking of headers in httpc:request

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Feb 5 14:42:56 MSK 2019


Hi! Thanks for the fixes! See 3 comments below.

>> 4. In the commit message you said that 'nil' is ok, but here you did not
>> check for that and return an error. Of course, real nil can not appear in
>> a table, because it means absence of a value, but what about box.NULL?
> 
> Added test for this case, right?

1. Yes, you did, but the test fails. On my laptop http_client.test.lua
is totally broken for already a year at least, but I run the test from
console and got this:

     	tarantool> client = require('http.client')
	---
	...

	tarantool> http = client:new()
	---
	...

	tarantool> opts = {headers = {aaa = box.NULL}}
	---
	...

	tarantool> http:get('127.0.0.1:12345', opts)
	---
	- error: 'builtin/http.client.lua:299: can''t convert header to a string'

So box.NULL is not converted to string despite the fact that box.NULL == nil
and you said in the commit message

     "... Each header must be nil, 'string' or 'table' ..."

> 
> 
>> 5. Out of 80 symbols.

2. Still out of 80.

>>
>>> +                } else if (luaL_getmetafield(L, -1, "__tostring") == LUA_TNIL) {
> diff --git a/test/app-tap/http_client.test.lua b/test/app-tap/http_client.test.lua
> index 10a3728f8..f231c2e90 100755
> --- a/test/app-tap/http_client.test.lua
> +++ b/test/app-tap/http_client.test.lua
> @@ -205,6 +205,80 @@ local function test_errors(test)
>       test:is(r.status, 595, "GET: response on bad url")
>   end
> 
> +-- gh-3679 allow only headers can be converted to string

3. I am not a linguist, but the sentence looks grammatically
incorrect IMO. 'Allow only headers <something is missing> can be ... '.

> +local function test_request_headers(test, url, opts)
> +    local exp_err = 'can\'t convert header to a string'
> +    local cases = {
> +        {




More information about the Tarantool-patches mailing list