Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
d7375662
Commit
d7375662
authored
Sep 25, 2015
by
Matt Burke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy custom_headers insteach of referencing the caller's copy
parent
d16c1b97
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
24 deletions
+26
-24
src/remote.c
+1
-1
src/transports/http.c
+3
-5
src/transports/smart.c
+9
-3
src/transports/smart.h
+1
-1
src/transports/winhttp.c
+12
-14
No files found.
src/remote.c
View file @
d7375662
...
@@ -689,7 +689,7 @@ int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs)
...
@@ -689,7 +689,7 @@ int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs)
static
int
set_transport_custom_headers
(
git_transport
*
t
,
const
git_strarray
*
custom_headers
)
static
int
set_transport_custom_headers
(
git_transport
*
t
,
const
git_strarray
*
custom_headers
)
{
{
if
(
!
t
->
set_custom_headers
||
!
custom_headers
)
if
(
!
t
->
set_custom_headers
)
return
0
;
return
0
;
return
t
->
set_custom_headers
(
t
,
custom_headers
);
return
t
->
set_custom_headers
(
t
,
custom_headers
);
...
...
src/transports/http.c
View file @
d7375662
...
@@ -211,11 +211,9 @@ static int gen_request(
...
@@ -211,11 +211,9 @@ static int gen_request(
}
else
}
else
git_buf_puts
(
buf
,
"Accept: */*
\r\n
"
);
git_buf_puts
(
buf
,
"Accept: */*
\r\n
"
);
if
(
t
->
owner
->
custom_headers
)
{
for
(
i
=
0
;
i
<
t
->
owner
->
custom_headers
.
count
;
i
++
)
{
for
(
i
=
0
;
i
<
t
->
owner
->
custom_headers
->
count
;
i
++
)
{
if
(
t
->
owner
->
custom_headers
.
strings
[
i
])
if
(
t
->
owner
->
custom_headers
->
strings
[
i
])
git_buf_printf
(
buf
,
"%s
\r\n
"
,
t
->
owner
->
custom_headers
.
strings
[
i
]);
git_buf_printf
(
buf
,
"%s
\r\n
"
,
t
->
owner
->
custom_headers
->
strings
[
i
]);
}
}
}
/* Apply credentials to the request */
/* Apply credentials to the request */
...
...
src/transports/smart.c
View file @
d7375662
...
@@ -124,6 +124,12 @@ static int git_smart__set_custom_headers(
...
@@ -124,6 +124,12 @@ static int git_smart__set_custom_headers(
transport_smart
*
t
=
(
transport_smart
*
)
transport
;
transport_smart
*
t
=
(
transport_smart
*
)
transport
;
size_t
i
;
size_t
i
;
if
(
t
->
custom_headers
.
count
)
git_strarray_free
(
&
t
->
custom_headers
);
if
(
!
custom_headers
)
return
0
;
for
(
i
=
0
;
i
<
custom_headers
->
count
;
i
++
)
{
for
(
i
=
0
;
i
<
custom_headers
->
count
;
i
++
)
{
if
(
is_malformed_http_header
(
custom_headers
->
strings
[
i
]))
{
if
(
is_malformed_http_header
(
custom_headers
->
strings
[
i
]))
{
giterr_set
(
GITERR_INVALID
,
"custom HTTP header '%s' is malformed"
,
custom_headers
->
strings
[
i
]);
giterr_set
(
GITERR_INVALID
,
"custom HTTP header '%s' is malformed"
,
custom_headers
->
strings
[
i
]);
...
@@ -135,9 +141,7 @@ static int git_smart__set_custom_headers(
...
@@ -135,9 +141,7 @@ static int git_smart__set_custom_headers(
}
}
}
}
t
->
custom_headers
=
custom_headers
;
return
git_strarray_copy
(
&
t
->
custom_headers
,
custom_headers
);
return
0
;
}
}
int
git_smart__update_heads
(
transport_smart
*
t
,
git_vector
*
symrefs
)
int
git_smart__update_heads
(
transport_smart
*
t
,
git_vector
*
symrefs
)
...
@@ -436,6 +440,8 @@ static void git_smart__free(git_transport *transport)
...
@@ -436,6 +440,8 @@ static void git_smart__free(git_transport *transport)
git_vector_free
(
refs
);
git_vector_free
(
refs
);
git_strarray_free
(
&
t
->
custom_headers
);
git__free
(
t
);
git__free
(
t
);
}
}
...
...
src/transports/smart.h
View file @
d7375662
...
@@ -139,7 +139,7 @@ typedef struct {
...
@@ -139,7 +139,7 @@ typedef struct {
git_transport_message_cb
error_cb
;
git_transport_message_cb
error_cb
;
git_transport_certificate_check_cb
certificate_check_cb
;
git_transport_certificate_check_cb
certificate_check_cb
;
void
*
message_cb_payload
;
void
*
message_cb_payload
;
const
git_strarray
*
custom_headers
;
git_strarray
custom_headers
;
git_smart_subtransport
*
wrapped
;
git_smart_subtransport
*
wrapped
;
git_smart_subtransport_stream
*
current_stream
;
git_smart_subtransport_stream
*
current_stream
;
transport_smart_caps
caps
;
transport_smart_caps
caps
;
...
...
src/transports/winhttp.c
View file @
d7375662
...
@@ -410,21 +410,19 @@ static int winhttp_stream_connect(winhttp_stream *s)
...
@@ -410,21 +410,19 @@ static int winhttp_stream_connect(winhttp_stream *s)
}
}
}
}
if
(
t
->
owner
->
custom_headers
)
{
for
(
i
=
0
;
i
<
t
->
owner
->
custom_headers
.
count
;
i
++
)
{
for
(
i
=
0
;
i
<
t
->
owner
->
custom_headers
->
count
;
i
++
)
{
if
(
t
->
owner
->
custom_headers
.
strings
[
i
])
{
if
(
t
->
owner
->
custom_headers
->
strings
[
i
])
{
git_buf_clear
(
&
buf
);
git_buf_clear
(
&
buf
);
git_buf_puts
(
&
buf
,
t
->
owner
->
custom_headers
.
strings
[
i
]);
git_buf_puts
(
&
buf
,
t
->
owner
->
custom_headers
->
strings
[
i
]);
if
(
git__utf8_to_16
(
ct
,
MAX_CONTENT_TYPE_LEN
,
git_buf_cstr
(
&
buf
))
<
0
)
{
if
(
git__utf8_to_16
(
ct
,
MAX_CONTENT_TYPE_LEN
,
git_buf_cstr
(
&
buf
))
<
0
)
{
giterr_set
(
GITERR_OS
,
"Failed to convert custom header to wide characters"
);
giterr_set
(
GITERR_OS
,
"Failed to convert custom header to wide characters"
);
goto
on_error
;
goto
on_error
;
}
}
if
(
!
WinHttpAddRequestHeaders
(
s
->
request
,
ct
,
(
ULONG
)
-
1L
,
if
(
!
WinHttpAddRequestHeaders
(
s
->
request
,
ct
,
(
ULONG
)
-
1L
,
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
))
{
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
))
{
giterr_set
(
GITERR_OS
,
"Failed to add a header to the request"
);
giterr_set
(
GITERR_OS
,
"Failed to add a header to the request"
);
goto
on_error
;
goto
on_error
;
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment