mirror of
https://git.proxmox.com/git/libgit2
synced 2025-10-18 19:14:55 +00:00
Merge pull request #1895 from libgit2/winhttp-accept
WinHTTP: set Accept header for POSTs
This commit is contained in:
commit
062c95c2a9
@ -265,15 +265,19 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
/* Send Content-Type header -- only necessary on a POST */
|
||||
if (post_verb == s->verb) {
|
||||
/* Send Content-Type and Accept headers -- only necessary on a POST */
|
||||
git_buf_clear(&buf);
|
||||
if (git_buf_printf(&buf, "Content-Type: application/x-git-%s-request", s->service) < 0)
|
||||
if (git_buf_printf(&buf,
|
||||
"Content-Type: application/x-git-%s-request\r\n"
|
||||
"Accept: application/x-git-%s-result\r\n",
|
||||
s->service, s->service) < 0)
|
||||
goto on_error;
|
||||
|
||||
git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf));
|
||||
|
||||
if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG) -1L, WINHTTP_ADDREQ_FLAG_ADD)) {
|
||||
if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG) -1L,
|
||||
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) {
|
||||
giterr_set(GITERR_OS, "Failed to add a header to the request");
|
||||
goto on_error;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define BB_REPO_URL "https://libgit2@bitbucket.org/libgit2/testgitrepository.git"
|
||||
#define BB_REPO_URL_WITH_PASS "https://libgit2:libgit2@bitbucket.org/libgit2/testgitrepository.git"
|
||||
#define BB_REPO_URL_WITH_WRONG_PASS "https://libgit2:wrong@bitbucket.org/libgit2/testgitrepository.git"
|
||||
#define ASSEMBLA_REPO_URL "https://libgit2:_Libgit2@git.assembla.com/libgit2-test-repos.git"
|
||||
|
||||
static git_repository *g_repo;
|
||||
static git_clone_options g_options;
|
||||
@ -227,6 +228,11 @@ void test_online_clone__bitbucket_style(void)
|
||||
cl_fixture_cleanup("./foo");
|
||||
}
|
||||
|
||||
void test_online_clone__assembla_style(void)
|
||||
{
|
||||
cl_git_pass(git_clone(&g_repo, ASSEMBLA_REPO_URL, "./foo", NULL));
|
||||
}
|
||||
|
||||
static int cancel_at_half(const git_transfer_progress *stats, void *payload)
|
||||
{
|
||||
GIT_UNUSED(payload);
|
||||
|
Loading…
Reference in New Issue
Block a user