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
5250fa9e
Unverified
Commit
5250fa9e
authored
Sep 19, 2022
by
Edward Thomson
Committed by
GitHub
Sep 19, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6363 from kcsaul/long_custom_header
winhttp: support long custom headers
parents
71071360
f5670326
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
src/libgit2/transports/winhttp.c
+9
-4
tests/libgit2/online/clone.c
+10
-0
No files found.
src/libgit2/transports/winhttp.c
View file @
5250fa9e
...
...
@@ -562,18 +562,23 @@ static int winhttp_stream_connect(winhttp_stream *s)
for
(
i
=
0
;
i
<
t
->
owner
->
connect_opts
.
custom_headers
.
count
;
i
++
)
{
if
(
t
->
owner
->
connect_opts
.
custom_headers
.
strings
[
i
])
{
wchar_t
*
custom_header_wide
=
NULL
;
git_str_clear
(
&
buf
);
git_str_puts
(
&
buf
,
t
->
owner
->
connect_opts
.
custom_headers
.
strings
[
i
]);
if
(
git__utf8_to_16
(
ct
,
MAX_CONTENT_TYPE_LEN
,
git_str_cstr
(
&
buf
))
<
0
)
{
git_error_set
(
GIT_ERROR_OS
,
"failed to convert custom header to wide characters"
);
/* Convert header to wide characters */
if
((
error
=
git__utf8_to_16_alloc
(
&
custom_header_wide
,
git_str_cstr
(
&
buf
)))
<
0
)
goto
on_error
;
}
if
(
!
WinHttpAddRequestHeaders
(
s
->
request
,
c
t
,
(
ULONG
)
-
1L
,
if
(
!
WinHttpAddRequestHeaders
(
s
->
request
,
c
ustom_header_wide
,
(
ULONG
)
-
1L
,
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
))
{
git_error_set
(
GIT_ERROR_OS
,
"failed to add a header to the request"
);
git__free
(
custom_header_wide
);
goto
on_error
;
}
git__free
(
custom_header_wide
);
}
}
...
...
tests/libgit2/online/clone.c
View file @
5250fa9e
...
...
@@ -309,6 +309,16 @@ void test_online_clone__custom_headers(void)
cl_git_pass
(
git_clone
(
&
g_repo
,
LIVE_REPO_URL
,
"./foo"
,
&
g_options
));
}
void
test_online_clone__long_custom_header
(
void
)
{
/* Long custom header with 1500 characters */
char
*
ok
=
"X-Custom: a0MsqH2bXV9lILn7zkAHqKpGrOVvkik7SfoyqfXbFTxccsymN5SG9hEB0RLD9koTXKWtaI1vI9jHf5ViwLHq6xvkveFX9GiqaIhe3TRu5KDZrOBgeufdBYsTTONALPlpni9XVq71bR6x3AlVEqHdXi9qiq0TRuNiujMy0ZKs8LQkQVSE8kxWZXqLsO2IJtAPw5aqsUEenK5ec12GOeOTOYlSChGllzvl2Ow4SKlVg3t8NHVWvc8HyPGmBQ79l3qUMU30P0hnUXaIrhIzGgleYWnwhGFLpryxsQfCdwkdBMuvtLH0DnkhLoAkCmnCZItEExtHBOCirEzztoFMX3lH4lM4wMqePCU8II0qloNvzPgt6cBThQJP66FYUDSCwsSb63bcTWdVx7TCa6mAplkP49PKi5pFSvFKKbs5se5MPcBVG03GiatKszIQkii0vp6OV5b54Aym4N8hQJHFMhIChKiQM91tB7PQu9vPJE6h2bzAnQsn34bBPFZHT7pBplqkASiHDjw69YV6k3M8ffTOTr2ibQnTKxh1NH3ZRx6u0KxRty9i4YLMniZUZAfFgqbSW2xXk49e8J9VNFm7j2bgHp3t813wUzqnQL4NEc0CQlF0e6pId5ADXikoH6S7aMfuYUYi1Kn1i9m7UGtaB0U7dVC65uH9vIWKnyAcmBt0mN1aikRnjz7oBKjD65SRZrKWXeCDJkpgWlXnD5JjekDCyB9m3yGkaxy1FflI1kaa4kcVbPRfs6XebHRDl9golPBUyazRG1V1iOi1mKki9ClUNO8wviNfKm5eMbWW6hU8wMXh388EotRA73TUdL4JIfNpkC4XBFLNFbFtltzO34kxXBKvhj8t0XVZOp4AWpHEL3pUtuyKhNWaWlDF6ZhjCeO8vT1akKoYaA7t6nFyqawq5nPoB0iXEHQ7YugfYfgjzpNGLgvPJ6aLg9YIKZBqfi7J9xWb356IJvTQFswi7qm6Mu7IVXarS9m84b5IfT6UCVq84u4VcdBlDswNPTw6SbBtzg9vrLLs3MoTCzJY6fHPqnKt6YthgQwOOB1ig7GTSDiX3W3SMeaz5jTASociHrUS3HrwVSgjrODnF86962cv4s3DGYjiX2cIuNfq9mZVJlNsylZjFYFV9LzOjNLlSHZVJrrGQJLjmyOCwOMkG9u2xKdSvfjxTJzqhjhTvQSQZWhKt44hA9EidUqPqjc3MhfnZ6aeAIP232gtRHoRc7FdjRSan4Q3PWy02YiRodvKAafonwCOtMcm4MASrXBiBE1tibHLSTtK4UrodFNVhymtBCRnJdVRSgrCQcr2B5Jzs4Iv6uJlJqwwyuq6In54zcmecgJZezta84B3eFoSGJhCbI6Zza0khulccglCcppciWDStAHFhncePsCQL4tup0Z8fS01RksRQ7X1xgskVvQAKELThDqbJB4FJZwrwPXOpCweAoSONntp7Ly0lAUabw75gK5sR387IxNVdISmfP"
;
g_options
.
fetch_opts
.
custom_headers
.
count
=
1
;
g_options
.
fetch_opts
.
custom_headers
.
strings
=
&
ok
;
cl_git_pass
(
git_clone
(
&
g_repo
,
LIVE_REPO_URL
,
"./foo"
,
&
g_options
));
}
static
int
cred_failure_cb
(
git_credential
**
cred
,
const
char
*
url
,
...
...
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