580
char *service_url;
581
char *hdr_content_type;
582
char *hdr_accept;
583
+ char *hdr_accept_language;
584
char *protocol_header;
585
char *buf;
586
size_t alloc;
608
unsigned flush_read_but_not_sent : 1;
609
};
610
611
+#define RPC_STATE_INIT { 0 }
612
+
613
/*
614
* Appends the result of reading from rpc->out to the string represented by
615
* rpc->buf and rpc->len if there is enough space. Returns 1 if there was
935
headers = curl_slist_append(headers, needs_100_continue ?
936
"Expect: 100-continue" : "Expect:");
937
938
+ /* Add Accept-Language header */
939
+ if (rpc->hdr_accept_language)
940
+ headers = curl_slist_append(headers, rpc->hdr_accept_language);
941
+
942
/* Add the extra Git-Protocol header */
943
if (rpc->protocol_header)
944
headers = curl_slist_append(headers, rpc->protocol_header);
1087
strbuf_addf(&buf, "%s%s", url.buf, svc);
1088
rpc->service_url = strbuf_detach(&buf, NULL);
1089
1090
+ rpc->hdr_accept_language = xstrdup_or_null(http_get_accept_language_header());
1091
+
1092
strbuf_addf(&buf, "Content-Type: application/x-%s-request", svc);
1093
rpc->hdr_content_type = strbuf_detach(&buf, NULL);
1094
1127
free(rpc->service_url);
1128
free(rpc->hdr_content_type);
1129
free(rpc->hdr_accept);
1130
+ free(rpc->hdr_accept_language);
1131
free(rpc->protocol_header);
1132
free(rpc->buf);
1133
strbuf_release(&buf);
1163
static int fetch_git(struct discovery *heads,
1164
int nr_heads, struct ref **to_fetch)
1165
{
1156
- struct rpc_state rpc;
1166
+ struct rpc_state rpc = RPC_STATE_INIT;
1167
struct strbuf preamble = STRBUF_INIT;
1168
int i, err;
1169
struct strvec args = STRVEC_INIT;
1309
1310
static int push_git(struct discovery *heads, int nr_spec, const char **specs)
1311
{
1302
- struct rpc_state rpc;
1312
+ struct rpc_state rpc = RPC_STATE_INIT;
1313
int i, err;
1314
struct strvec args;
1315
struct string_list_item *cas_option;
1408
static int stateless_connect(const char *service_name)
1409
{
1410
struct discovery *discover;
1401
- struct rpc_state rpc;
1411
+ struct rpc_state rpc = RPC_STATE_INIT;
1412
struct strbuf buf = STRBUF_INIT;
1413
+ const char *accept_language;
1414
1415
/*
1416
* Run the info/refs request and see if the server supports protocol
1429
printf("\n");
1430
fflush(stdout);
1431
}
1432
+ accept_language = http_get_accept_language_header();
1433
+ if (accept_language)
1434
+ rpc.hdr_accept_language = xstrfmt("%s", accept_language);
1435
1436
rpc.service_name = service_name;
1437
rpc.service_url = xstrfmt("%s%s", url.buf, rpc.service_name);
1481
free(rpc.service_url);
1482
free(rpc.hdr_content_type);
1483
free(rpc.hdr_accept);
1484
+ free(rpc.hdr_accept_language);
1485
free(rpc.protocol_header);
1486
free(rpc.buf);
1487
strbuf_release(&buf);