http-backend: respect CONTENT_LENGTH for receive-pack
commit6c213e863aeb0af078bf82deefb22da20427c2ab
authorMax Kirillov <max@max630.net>
Fri, 27 Jul 2018 03:48:59 +0000 (27 06:48 +0300)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Jul 2018 17:47:52 +0000 (27 10:47 -0700)
treee57aa5d2f715e46fc3605bf659322a1ed747e195
parentc79edf73f4b018310428632887f9ce2ce32d839a
http-backend: respect CONTENT_LENGTH for receive-pack

Push passes to another commands, as described in
https://public-inbox.org/git/20171129032214.GB32345@sigill.intra.peff.net/

As it gets complicated to correctly track the data length, instead transfer
the data through parent process and cut the pipe as the specified length is
reached. Do it only when CONTENT_LENGTH is set, otherwise pass the input
directly to the forked commands.

Add tests for cases:

* CONTENT_LENGTH is set, script's stdin has more data, with all combinations
  of variations: fetch or push, plain or compressed body, correct or truncated
  input.

* CONTENT_LENGTH is specified to a value which does not fit into ssize_t.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
help.c
http-backend.c
t/t5562-http-backend-content-length.sh [new file with mode: 0755]
t/t5562/invoke-with-content-length.pl [new file with mode: 0755]