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
4ef2b889
Unverified
Commit
4ef2b889
authored
Nov 18, 2018
by
Edward Thomson
Committed by
GitHub
Nov 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4882 from kc8apf/include_port_in_host_header
transport/http: Include non-default ports in Host header
parents
7321cff0
83b35181
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
src/netops.c
+12
-3
src/netops.h
+2
-0
src/transports/http.c
+5
-1
No files found.
src/netops.c
View file @
4ef2b889
...
...
@@ -119,6 +119,15 @@ int gitno__match_host(const char *pattern, const char *host)
return
-
1
;
}
static
const
char
*
default_port_http
=
"80"
;
static
const
char
*
default_port_https
=
"443"
;
const
char
*
gitno__default_port
(
gitno_connection_data
*
data
)
{
return
data
->
use_ssl
?
default_port_https
:
default_port_http
;
}
static
const
char
*
prefix_http
=
"http://"
;
static
const
char
*
prefix_https
=
"https://"
;
...
...
@@ -141,7 +150,7 @@ int gitno_connection_data_from_url(
if
(
!
git__prefixcmp
(
url
,
prefix_http
))
{
path_search_start
=
url
+
strlen
(
prefix_http
);
default_port
=
"80"
;
default_port
=
default_port_http
;
if
(
data
->
use_ssl
)
{
giterr_set
(
GITERR_NET
,
"redirect from HTTPS to HTTP is not allowed"
);
...
...
@@ -149,10 +158,10 @@ int gitno_connection_data_from_url(
}
}
else
if
(
!
git__prefixcmp
(
url
,
prefix_https
))
{
path_search_start
=
url
+
strlen
(
prefix_https
);
default_port
=
"443"
;
default_port
=
default_port_https
;
data
->
use_ssl
=
true
;
}
else
if
(
url
[
0
]
==
'/'
)
default_port
=
data
->
use_ssl
?
"443"
:
"80"
;
default_port
=
gitno__default_port
(
data
)
;
if
(
!
default_port
)
{
giterr_set
(
GITERR_NET
,
"unrecognized URL prefix"
);
...
...
src/netops.h
View file @
4ef2b889
...
...
@@ -96,4 +96,6 @@ int gitno_extract_url_parts(
const
char
*
url
,
const
char
*
default_port
);
const
char
*
gitno__default_port
(
gitno_connection_data
*
data
);
#endif
src/transports/http.c
View file @
4ef2b889
...
...
@@ -208,7 +208,11 @@ static int gen_request(
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
"
,
t
->
connection_data
.
host
);
git_buf_printf
(
buf
,
"Host: %s"
,
t
->
connection_data
.
host
);
if
(
strcmp
(
t
->
connection_data
.
port
,
gitno__default_port
(
&
t
->
connection_data
))
!=
0
)
{
git_buf_printf
(
buf
,
":%s"
,
t
->
connection_data
.
port
);
}
git_buf_puts
(
buf
,
"
\r\n
"
);
if
(
s
->
chunked
||
content_length
>
0
)
{
git_buf_printf
(
buf
,
"Accept: application/x-git-%s-result
\r\n
"
,
s
->
service
);
...
...
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