Commit 276f6aa08d4cb35ad647b24bfa254b99af89e076

Matt Burke 2015-09-08T14:00:37

Hook up the custom_headers to the http transport

diff --git a/src/transports/http.c b/src/transports/http.c
index d348310..764c6a9 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -211,10 +211,9 @@ static int gen_request(
 	} else
 		git_buf_puts(buf, "Accept: */*\r\n");
 
-	if (t->connection_data.extra_headers) {
-		for (i = 0; i < t->connection_data.extra_headers->count; i++) {
-			git_buf_puts(buf, t->connection_data.extra_headers->strings[i]);
-			git_buf_puts(buf, "\r\n");
+	if (t->owner->custom_headers) {
+		for (i = 0; i < t->owner->custom_headers->count; i++) {
+			git_buf_printf(buf, "%s\r\n", t->owner->custom_headers->strings[i]);
 		}
 	}
 
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 31a2dec..15f45e1 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -66,6 +66,17 @@ static int git_smart__set_callbacks(
 	return 0;
 }
 
+static int git_smart__set_custom_headers(
+	git_transport *transport,
+	const git_strarray *custom_headers)
+{
+	transport_smart *t = (transport_smart *)transport;
+
+	t->custom_headers = custom_headers;
+
+	return 0;
+}
+
 int git_smart__update_heads(transport_smart *t, git_vector *symrefs)
 {
 	size_t i;
@@ -399,6 +410,7 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param)
 
 	t->parent.version = GIT_TRANSPORT_VERSION;
 	t->parent.set_callbacks = git_smart__set_callbacks;
+	t->parent.set_custom_headers = git_smart__set_custom_headers;
 	t->parent.connect = git_smart__connect;
 	t->parent.close = git_smart__close;
 	t->parent.free = git_smart__free;
diff --git a/src/transports/smart.h b/src/transports/smart.h
index 4c728c7..2c87e02 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -139,6 +139,7 @@ typedef struct {
 	git_transport_message_cb error_cb;
 	git_transport_certificate_check_cb certificate_check_cb;
 	void *message_cb_payload;
+	const git_strarray *custom_headers;
 	git_smart_subtransport *wrapped;
 	git_smart_subtransport_stream *current_stream;
 	transport_smart_caps caps;