From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 7 Mar 2019 17:32:20 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] Re: [PATCH v1 1/1] http: fix httpc auto-managed headers Message-ID: <20190307143220.ihg2sjjwtb3k476q@esperanza> References: <9099f8a339c278e3a5dac683923d13c7ee470ce9.1550761676.git.kshcherbatov@tarantool.org> <80130a1b-84ad-5f90-9422-95bb0a1e67cb@tarantool.org> <998b800b-acc1-f0c8-1fd3-322d0c04f657@tarantool.org> <20190307135135.dner6r66szejw6lx@esperanza> <607fe6de-8db7-d379-a2f7-888f602796b5@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <607fe6de-8db7-d379-a2f7-888f602796b5@tarantool.org> To: Kirill Shcherbatov Cc: Tarantool MailList List-ID: On Thu, Mar 07, 2019 at 05:07:04PM +0300, Kirill Shcherbatov wrote: > >> + /* > >> + * The sequence of managed headers must be sorted to > >> + * stop scan when strcasecmp < 0. The header is expected > >> + * to be formated with "%s: %s" pattern, so direct size > >> + * verification is redundant. > >> + */ > >> + struct { > >> + const char *name; > >> + int len; > >> + } managed_headers[] = { > >> + {"Accept: ", sizeof("Accept: ") - 1}, > >> + {"Connection: ", sizeof("Connection: ") - 1}, > >> + {"Content-Length: ", sizeof("Content-Length: ") - 1}, > >> + {"Keep-Alive: ", sizeof("Keep-Alive: ") - 1}, > > > > - A space after a colon (:) isn't mandatory according to the http > > protocol, e.g. "content-length:10" is a valid header. > All headers are formated by server earlier, so this is acceptable: > if (httpc_set_header(req, "%s: %s", > lua_tostring(L, -2), > lua_tostring(L, -1)) < 0) { > httpc_request_delete(req); > return luaT_error(L); > } Yeah, okay, but looks kinda fragile if you consider the httpc module on its own, without looking at the Lua binding code. So please change.