Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-10-03 01:45:57 +0400
committerBen Straub <bs@github.com>2013-10-03 01:45:57 +0400
commit41a6de289fecbec426d2d977c4d02da5456701ac (patch)
treedfad243df0578ff3cc555d23dab65c8f43d03b51 /src/netops.c
parent5bfead1dba919f6b47f52da675ea94407e8baf49 (diff)
HTTP: handle "relative" redirects
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/netops.c b/src/netops.c
index 3257e7749..7a61ef820 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -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);