http: also store Content-Type if it's the last field

When Content-Type is the last field, we only know when we can store it
when we reach on_headers_complete.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
Carlos Martín Nieto 2011-09-11 14:51:27 +02:00
parent 5604f92880
commit 7e08191a06

View File

@ -181,6 +181,12 @@ static int on_headers_complete(http_parser *parser)
transport_http *t = (transport_http *) parser->data; transport_http *t = (transport_http *) parser->data;
git_buf *buf = &t->buf; git_buf *buf = &t->buf;
if (t->content_type == NULL) {
t->content_type = git__strdup(git_buf_cstr(buf));
if (t->content_type == NULL)
return t->error = GIT_ENOMEM;
}
git_buf_clear(buf); git_buf_clear(buf);
git_buf_printf(buf, "application/x-git-%s-advertisement", t->service); git_buf_printf(buf, "application/x-git-%s-advertisement", t->service);
if (git_buf_oom(buf)) if (git_buf_oom(buf))