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
2807de5c
Commit
2807de5c
authored
Dec 17, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: handle ipv6 addresses
parent
780ad7a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
10 deletions
+30
-10
src/transports/httpclient.c
+30
-10
No files found.
src/transports/httpclient.c
View file @
2807de5c
...
...
@@ -631,6 +631,26 @@ GIT_INLINE(int) apply_proxy_credentials(
request
->
proxy_credentials
);
}
static
int
puts_host_and_port
(
git_buf
*
buf
,
git_net_url
*
url
,
bool
force_port
)
{
bool
ipv6
=
git_net_url_is_ipv6
(
url
);
if
(
ipv6
)
git_buf_putc
(
buf
,
'['
);
git_buf_puts
(
buf
,
url
->
host
);
if
(
ipv6
)
git_buf_putc
(
buf
,
']'
);
if
(
force_port
||
!
git_net_url_is_default_port
(
url
))
{
git_buf_putc
(
buf
,
':'
);
git_buf_puts
(
buf
,
url
->
port
);
}
return
git_buf_oom
(
buf
)
?
-
1
:
0
;
}
static
int
generate_connect_request
(
git_http_client
*
client
,
git_http_request
*
request
)
...
...
@@ -641,14 +661,17 @@ static int generate_connect_request(
git_buf_clear
(
&
client
->
request_msg
);
buf
=
&
client
->
request_msg
;
git_buf_printf
(
buf
,
"CONNECT %s:%s HTTP/1.1
\r\n
"
,
client
->
server
.
url
.
host
,
client
->
server
.
url
.
port
);
git_buf_puts
(
buf
,
"CONNECT "
);
puts_host_and_port
(
buf
,
&
client
->
server
.
url
,
true
);
git_buf_puts
(
buf
,
" HTTP/1.1
\r\n
"
);
git_buf_puts
(
buf
,
"User-Agent: "
);
git_http__user_agent
(
buf
);
git_buf_puts
(
buf
,
"
\r\n
"
);
git_buf_printf
(
buf
,
"Host: %s
\r\n
"
,
client
->
proxy
.
url
.
host
);
git_buf_puts
(
buf
,
"Host: "
);
puts_host_and_port
(
buf
,
&
client
->
proxy
.
url
,
false
);
git_buf_puts
(
buf
,
"
\r\n
"
);
if
((
error
=
apply_proxy_credentials
(
buf
,
client
,
request
)
<
0
))
return
-
1
;
...
...
@@ -687,11 +710,8 @@ static int generate_request(
git_http__user_agent
(
buf
);
git_buf_puts
(
buf
,
"
\r\n
"
);
git_buf_printf
(
buf
,
"Host: %s"
,
request
->
url
->
host
);
if
(
!
git_net_url_is_default_port
(
request
->
url
))
git_buf_printf
(
buf
,
":%s"
,
request
->
url
->
port
);
git_buf_puts
(
buf
,
"Host: "
);
puts_host_and_port
(
buf
,
request
->
url
,
false
);
git_buf_puts
(
buf
,
"
\r\n
"
);
if
(
request
->
accept
)
...
...
@@ -902,7 +922,7 @@ static int proxy_connect(
int
error
;
if
(
!
client
->
proxy_connected
||
!
client
->
keepalive
)
{
git_trace
(
GIT_TRACE_DEBUG
,
"Connecting to proxy %s
:
%s"
,
git_trace
(
GIT_TRACE_DEBUG
,
"Connecting to proxy %s
port
%s"
,
client
->
proxy
.
url
.
host
,
client
->
proxy
.
url
.
port
);
if
((
error
=
server_create_stream
(
&
client
->
proxy
))
<
0
||
...
...
@@ -1023,7 +1043,7 @@ static int http_client_connect(
goto
on_error
;
}
git_trace
(
GIT_TRACE_DEBUG
,
"Connecting to remote %s
:
%s"
,
git_trace
(
GIT_TRACE_DEBUG
,
"Connecting to remote %s
port
%s"
,
client
->
server
.
url
.
host
,
client
->
server
.
url
.
port
);
if
((
error
=
server_connect
(
client
))
<
0
)
...
...
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