Visitar URL original
Custom push headers by srajko · Pull Request #4 · nodegit/libgit2 · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow the world to set HTTP headers for remotes
  • Loading branch information
spraints authored and srajko committed Jan 26, 2016
commit fa39651e4ded7e3de5f4686055cb712c8aa2d4fe
3 changes: 3 additions & 0 deletions include/git2/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ GIT_EXTERN(size_t) git_remote_refspec_count(const git_remote *remote);
*/
GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote, size_t n);

GIT_EXTERN(int) git_remote_extra_http_headers(const git_remote *remote, git_strarray *extra_http_headers);
GIT_EXTERN(int) git_remote_set_extra_http_headers(git_remote *remote, const git_strarray extra_http_headers);

/**
* Open a connection to a remote
*
Expand Down
12 changes: 11 additions & 1 deletion src/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ void git_remote_free(git_remote *remote)
free_refspecs(&remote->passive_refspecs);
git_vector_free(&remote->passive_refspecs);

git__free(remote->extra_http_headers);
git_strarray_free(&remote->extra_http_headers);

git_push_free(remote->push);
git__free(remote->url);
Expand Down Expand Up @@ -2145,6 +2145,16 @@ size_t git_remote_refspec_count(const git_remote *remote)
return remote->refspecs.length;
}

int git_remote_extra_http_headers(const git_remote *remote, git_strarray *extra_http_headers)
{
return git_strarray_copy(extra_http_headers, &remote->extra_http_headers);
}

int git_remote_set_extra_http_headers(git_remote *remote, const git_strarray extra_http_headers)
{
return git_strarray_copy(&remote->extra_http_headers, &extra_http_headers);
}

const git_refspec *git_remote_get_refspec(const git_remote *remote, size_t n)
{
return git_vector_get(&remote->refspecs, n);
Expand Down
2 changes: 1 addition & 1 deletion src/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct git_remote {
git_remote_autotag_option_t download_tags;
int prune_refs;
int passed_refspecs;
git_strarray *extra_http_headers;
git_strarray extra_http_headers;
};

const char* git_remote__urlfordirection(struct git_remote *remote, int direction);
Expand Down
2 changes: 1 addition & 1 deletion src/transports/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ static int http_action(
if ((!t->connection_data.host || !t->connection_data.port || !t->connection_data.path) &&
(ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0)
return ret;
t->connection_data.extra_headers = t->owner->owner->extra_http_headers;
t->connection_data.extra_headers = &t->owner->owner->extra_http_headers;

if ((ret = http_connect(t)) < 0)
return ret;
Expand Down