return 0;
}
+/* Regardless of the specified URL, make sure path ends in '/' */
+static char *solr_connection_create_http_base_url(struct http_url *http_url)
+{
+ if (http_url->path == NULL)
+ return i_strconcat("/", http_url->enc_query, NULL);
+ size_t len = strlen(http_url->path);
+ if (len > 0 && http_url->path[len-1] != '/')
+ return i_strconcat(http_url->path, "/",
+ http_url->enc_query, NULL);
+ /* http_url->path is NULL on empty path, so this is impossible. */
+ i_assert(len != 0);
+ return i_strconcat(http_url->path, http_url->enc_query, NULL);
+}
+
int solr_connection_init(const char *url,
const struct ssl_iostream_settings *ssl_client_set,
bool debug, struct solr_connection **conn_r,
conn = i_new(struct solr_connection, 1);
conn->http_host = i_strdup(http_url->host.name);
conn->http_port = http_url->port;
- conn->http_base_url = i_strconcat(http_url->path, http_url->enc_query, NULL);
+ conn->http_base_url = solr_connection_create_http_base_url(http_url);
conn->http_ssl = http_url->have_ssl;
if (http_url->user != NULL) {
conn->http_user = i_strdup(http_url->user);