diff --git a/src/protocol/uri.c b/src/protocol/uri.c index 88020dcc..d3979b28 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -460,6 +460,8 @@ struct string * add_uri_to_string(struct string *string, struct uri *uri, enum uri_component components) { + int add_host = 0; + /* Custom or unknown keep the URI untouched. */ if (uri->protocol == PROTOCOL_UNKNOWN) return add_to_string(string, struri(uri)); @@ -486,7 +488,7 @@ add_uri_to_string(struct string *string, struct uri *uri, } if (wants(URI_HOST) && uri->hostlen) { - int add_host = 1; + add_host = 1; #ifdef CONFIG_IPV6 /* Rationale for wants(URI_PORT): The [notation] was invented @@ -550,7 +552,7 @@ add_uri_to_string(struct string *string, struct uri *uri, } /* Only add slash if we need to separate */ - if ((wants(URI_DATA) || wants(URI_POST)) + if ((wants(URI_DATA) || wants(URI_POST) || add_host) && wants(~(URI_DATA | URI_PORT)) && get_protocol_need_slash_after_host(uri->protocol)) add_char_to_string(string, '/');