# What happen if show_http_message fails to reencode?

2 messages from 2015-04-20 to 2015-04-20. Participants: Yi, EungJun, Junio C Hamano.
Thread: https://gitlist.dev/t/39114

## Yi, EungJun, 2015-04-20 06:29

Subject: What happen if show_http_message fails to reencode?
Message-ID: <CAFT+Tg9x3QfS4c93Bs_Oq0zc7bXvZdFZQAKJFPtqbp6M=Q-P0g@mail.gmail.com>
URL: https://gitlist.dev/e/CAFT%2BTg9x3QfS4c93Bs_Oq0zc7bXvZdFZQAKJFPtqbp6M%3DQ-P0g%40mail.gmail.com

```
I'm trying to make my git server sends http messages in non-ASCII
encoding. And I have a question.

At 206-218 in remote-curl.c:

> static int show_http_message(struct strbuf *type, struct strbuf *charset,
>                  struct strbuf *msg)
> {
>     const char *p, *eol;
>
>     /*
>      * We only show text/plain parts, as other types are likely
>      * to be ugly to look at on the user's terminal.
>      */
>     if (strcmp(type->buf, "text/plain"))
>         return -1;
>     if (charset->len)
>         strbuf_reencode(msg, charset->buf, get_log_output_encoding());

What happen if the message has a character which cannot be encoded by
the encoding defined by i18n.logoutputencoding? Drops only the
character or brakes the whole message?

-EungJun

```

## Junio C Hamano, 2015-04-20 16:46

Subject: Re: What happen if show_http_message fails to reencode?
Message-ID: <xmqqk2x6n3ws.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqk2x6n3ws.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CAFT+Tg9x3QfS4c93Bs_Oq0zc7bXvZdFZQAKJFPtqbp6M=Q-P0g@mail.gmail.com>

```
"Yi, EungJun" <semtlenori@gmail.com> writes:

> I'm trying to make my git server sends http messages in non-ASCII
> encoding. And I have a question.
>
> At 206-218 in remote-curl.c:
>
>> static int show_http_message(struct strbuf *type, struct strbuf *charset,
>>                  struct strbuf *msg)
>> {
>>     const char *p, *eol;
>>
>>     /*
>>      * We only show text/plain parts, as other types are likely
>>      * to be ugly to look at on the user's terminal.
>>      */
>>     if (strcmp(type->buf, "text/plain"))
>>         return -1;
>>     if (charset->len)
>>         strbuf_reencode(msg, charset->buf, get_log_output_encoding());
>
> What happen if the message has a character which cannot be encoded by
> the encoding defined by i18n.logoutputencoding? Drops only the
> character or brakes the whole message?

I think the implementation of strbuf_reencode() should tell you
quickly, but otherwise it may warrant a sentence or two of
commenting there.  It leaves the msg intact when underlying iconv()
reports that it couldn't reencode, so you should get the original
message literally.

```
