From: Junio C Hamano Date: Mon, 16 Jun 2014 19:18:35 +0000 (-0700) Subject: Merge branch 'jk/http-errors' X-Git-Tag: v2.1.0-rc0~112 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2075a0c27fa5cf4f9f03964d407dc015c1749a7e Merge branch 'jk/http-errors' Propagate the error messages from the webserver better to the client coming over the HTTP transport. * jk/http-errors: http: default text charset to iso-8859-1 remote-curl: reencode http error messages strbuf: add strbuf_reencode helper http: optionally extract charset parameter from content-type http: extract type/subtype portion of content-type t5550: test display of remote http error messages t/lib-httpd: use write_script to copy CGI scripts test-lib: preserve GIT_CURL_VERBOSE from the environment --- 2075a0c27fa5cf4f9f03964d407dc015c1749a7e diff --cc Documentation/technical/api-strbuf.txt index 50690186d3,9d28b034ad..077a7096a4 --- a/Documentation/technical/api-strbuf.txt +++ b/Documentation/technical/api-strbuf.txt @@@ -130,14 -125,11 +130,19 @@@ Function Strip whitespace from the end of a string. +`strbuf_ltrim`:: + + Strip whitespace from the beginning of a string. + + `strbuf_reencode`:: + + Replace the contents of the strbuf with a reencoded form. Returns -1 + on error, 0 on success. + +`strbuf_tolower`:: + + Lowercase each character in the buffer using `tolower`. + `strbuf_cmp`:: Compare two buffers. Returns an integer less than, equal to, or greater diff --cc strbuf.c index c8217755e5,fc7290f57a..ac62982e67 --- a/strbuf.c +++ b/strbuf.c @@@ -99,13 -107,22 +100,29 @@@ void strbuf_ltrim(struct strbuf *sb sb->buf[sb->len] = '\0'; } + int strbuf_reencode(struct strbuf *sb, const char *from, const char *to) + { + char *out; + int len; + + if (same_encoding(from, to)) + return 0; + + out = reencode_string_len(sb->buf, sb->len, to, from, &len); + if (!out) + return -1; + + strbuf_attach(sb, out, len, len); + return 0; + } + +void strbuf_tolower(struct strbuf *sb) +{ + char *p = sb->buf, *end = sb->buf + sb->len; + for (; p < end; p++) + *p = tolower(*p); +} + struct strbuf **strbuf_split_buf(const char *str, size_t slen, int terminator, int max) { diff --cc strbuf.h index 25328b9e81,4e9a2f8868..e9ad03eabe --- a/strbuf.h +++ b/strbuf.h @@@ -45,7 -45,7 +45,8 @@@ static inline void strbuf_setlen(struc extern void strbuf_trim(struct strbuf *); extern void strbuf_rtrim(struct strbuf *); extern void strbuf_ltrim(struct strbuf *); + extern int strbuf_reencode(struct strbuf *sb, const char *from, const char *to); +extern void strbuf_tolower(struct strbuf *sb); extern int strbuf_cmp(const struct strbuf *, const struct strbuf *); /*