Skip to content

Commit

Permalink
Allow for more Solr URL schemas YAZ-893
Browse files Browse the repository at this point in the history
If the Solr URL contains ? it will be treated as a URL that
includes request handler rather than hard-coded /select. For example
/solr/search? . You can also pass own arguments. For example
/solr/search?foo=bar .
  • Loading branch information
adamdickmeiss committed Jul 28, 2017
1 parent 248cdad commit 8ce0c3a
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/solr.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
char *path;
char *q;
char *cp;
const char *path_args = 0;
int i = 0;
int defType_set = 0;
int no_parms = 20; /* safe upper limit of args without extra_args */
Expand Down Expand Up @@ -593,26 +592,26 @@ int yaz_solr_encode_request(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
cp = strchr(hreq->path, '#');
if (cp)
*cp = '\0';
cp = strchr(hreq->path, '?');
if (cp)
{
*cp = '\0'; /* args in path */
path_args = cp + 1;
}
strcpy(path, hreq->path);
cp = strrchr(path, '/');
if (cp)
{
if (!strcmp(cp, "/select") || !strcmp(cp, "/"))
*cp = '\0';
cp = strchr(path, '?');
if (cp && strcmp(solr_op, "terms"))
{ /* complete path with requestHandler */
int last = path[strlen(path)-1];
if (last != '?' && last != '&')
strcat(path, "&");
}
strcat(path, "/");
strcat(path, solr_op);
strcat(path, "?");
if (path_args)
else
{
strcat(path, path_args);
strcat(path, "&");
/* add requestHandler ourselves */
cp = strrchr(path, '/');
if (cp)
{
if (!strcmp(cp, "/select") || !strcmp(cp, "/"))
*cp = '\0';
}
strcat(path, "/");
strcat(path, solr_op);
strcat(path, "?");
}
strcat(path, uri_args);
hreq->path = path;
Expand Down

0 comments on commit 8ce0c3a

Please sign in to comment.