Merge branch 'mk/http-backend-content-length'

The earlier attempt barfed when given a CONTENT_LENGTH that is
set to an empty string.  RFC 3875 is fairly clear that in this
case we should not read any message body, but we've been reading
through to the EOF in previous versions (which did not even pay
attention to the environment variable), so keep that behaviour for
now in this late update.

* mk/http-backend-content-length:
  http-backend: allow empty CONTENT_LENGTH
maint
Junio C Hamano 2018-09-10 10:29:16 -07:00
commit fe468efff5
2 changed files with 12 additions and 1 deletions

View File

@ -353,7 +353,7 @@ static ssize_t get_content_length(void)
ssize_t val = -1;
const char *str = getenv("CONTENT_LENGTH");

if (str && !git_parse_ssize_t(str, &val))
if (str && *str && !git_parse_ssize_t(str, &val))
die("failed to parse CONTENT_LENGTH: %s", str);
return val;
}

View File

@ -153,4 +153,15 @@ test_expect_success 'CONTENT_LENGTH overflow ssite_t' '
grep "fatal:.*CONTENT_LENGTH" err
'

test_expect_success 'empty CONTENT_LENGTH' '
env \
QUERY_STRING=/repo.git/HEAD \
PATH_TRANSLATED="$PWD"/.git/HEAD \
GIT_HTTP_EXPORT_ALL=TRUE \
REQUEST_METHOD=GET \
CONTENT_LENGTH="" \
git http-backend <empty_body >act.out 2>act.err &&
verify_http_result "200 OK"
'

test_done