Re: [PATCH v5 1/2] http-backend: respect CONTENT_LENGTH as specified by rfc3875
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 26, 2017, 09:38 UTC
- Message-ID
- <xmqq3751idmp.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20171126081329.GD26158@jessie.local>
Max Kirillov <max@max630.net> writes:
> I'm afraid I did not get the reasonsing and not fully the > desired change. Is this http-backend code change (compared > to the last patch) what you mean?
Exactly.
The fact that the parsed string happens to come from CONTENT_LENGTH environment variable is http's business, not parsers for various types of values that come in the form of strings.
Show 7 quoted lines
> --- a/http-backend.c > +++ b/http-backend.c > @@ -346,9 +346,18 @@ static ssize_t read_request_fixed_len(int fd, ssize_t req_len, unsigned char **o > } > } > > +static ssize_t env_content_length()
We need s/length()/length(void)/; though.
Show 15 quoted lines
> +{
> + const char *str = getenv("CONTENT_LENGTH");
> + ssize_t val = -1;
> + if (str && !git_parse_ssize_t(str, &val))
> + die("failed to parse CONTENT_LENGTH: %s", str);
> + return val;
> +}
> +
> static ssize_t read_request(int fd, unsigned char **out)
> {
> - ssize_t req_len = git_env_ssize_t("CONTENT_LENGTH", -1);
> + ssize_t req_len = env_content_length();
> if (req_len < 0)
> return read_request_eof(fd, out);
> else