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
41a6de28
Commit
41a6de28
authored
Oct 02, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HTTP: handle "relative" redirects
parent
5bfead1d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
src/netops.c
+10
-0
tests-clar/network/urlparse.c
+28
-0
No files found.
src/netops.c
View file @
41a6de28
...
...
@@ -609,6 +609,9 @@ int gitno_connection_data_from_url(
data
->
use_ssl
=
true
;
}
if
(
url
[
0
]
==
'/'
)
default_port
=
data
->
use_ssl
?
"443"
:
"80"
;
if
(
!
default_port
)
{
giterr_set
(
GITERR_NET
,
"Unrecognized URL prefix"
);
goto
cleanup
;
...
...
@@ -618,6 +621,13 @@ int gitno_connection_data_from_url(
&
data
->
host
,
&
data
->
port
,
&
data
->
user
,
&
data
->
pass
,
url
,
default_port
);
if
(
url
[
0
]
==
'/'
)
{
/* Relative redirect; reuse original host name and port */
git__free
(
data
->
host
);
data
->
host
=
original_host
;
original_host
=
NULL
;
}
if
(
!
error
)
{
const
char
*
path
=
strchr
(
url
,
'/'
);
size_t
pathlen
=
strlen
(
path
);
...
...
tests-clar/network/urlparse.c
View file @
41a6de28
...
...
@@ -125,6 +125,34 @@ void test_network_urlparse__connection_data_http_downgrade(void)
-
1
);
}
void
test_network_urlparse__connection_data_relative_redirect
(
void
)
{
cl_git_pass
(
gitno_connection_data_from_url
(
&
conndata
,
"http://foo.com/bar/baz/biff"
,
NULL
));
cl_git_pass
(
gitno_connection_data_from_url
(
&
conndata
,
"/zap/baz/biff?bam"
,
NULL
));
cl_assert_equal_s
(
conndata
.
host
,
"foo.com"
);
cl_assert_equal_s
(
conndata
.
port
,
"80"
);
cl_assert_equal_s
(
conndata
.
path
,
"/zap/baz/biff?bam"
);
cl_assert_equal_p
(
conndata
.
user
,
NULL
);
cl_assert_equal_p
(
conndata
.
pass
,
NULL
);
cl_assert_equal_i
(
conndata
.
use_ssl
,
false
);
}
void
test_network_urlparse__connection_data_relative_redirect_ssl
(
void
)
{
cl_git_pass
(
gitno_connection_data_from_url
(
&
conndata
,
"https://foo.com/bar/baz/biff"
,
NULL
));
cl_git_pass
(
gitno_connection_data_from_url
(
&
conndata
,
"/zap/baz/biff?bam"
,
NULL
));
cl_assert_equal_s
(
conndata
.
host
,
"foo.com"
);
cl_assert_equal_s
(
conndata
.
port
,
"443"
);
cl_assert_equal_s
(
conndata
.
path
,
"/zap/baz/biff?bam"
);
cl_assert_equal_p
(
conndata
.
user
,
NULL
);
cl_assert_equal_p
(
conndata
.
pass
,
NULL
);
cl_assert_equal_i
(
conndata
.
use_ssl
,
true
);
}
/* Run this under valgrind */
void
test_network_urlparse__connection_data_cleanup
(
void
)
{
...
...
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