X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fsrwutil.c;h=f7f0a1c9bfc73b9c07c673aec1437db5187de07d;hb=cf3ff0df41755297543b14f007842e1dc216ec25;hp=b2fc44d3345c94fb30d372af46b0319ac977281b;hpb=43a7aff23f364fd3fac6e9746c53cda01be13738;p=yaz-moved-to-github.git diff --git a/src/srwutil.c b/src/srwutil.c index b2fc44d..f7f0a1c 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: srwutil.c,v 1.29 2005-08-22 20:34:21 adam Exp $ + * $Id: srwutil.c,v 1.31 2005-09-12 10:23:53 adam Exp $ */ /** * \file srwutil.c @@ -29,17 +29,18 @@ int yaz_uri_array(const char *path, ODR o, char ***name, char ***val) int no = 2; const char *cp; *name = 0; - if (*path != '?') + if (*path == '?') + path++; + if (!*path) return no; - path++; cp = path; while ((cp = strchr(cp, '&'))) { cp++; no++; } - *name = odr_malloc(o, no * sizeof(char**)); - *val = odr_malloc(o, no * sizeof(char**)); + *name = odr_malloc(o, no * sizeof(char*)); + *val = odr_malloc(o, no * sizeof(char*)); for (no = 0; *path; no++) { @@ -251,8 +252,21 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu, {0, 0, 0} }; #endif - if (!strcmp(hreq->method, "GET") || - !strcmp(hreq->method, "POST") ) + const char *content_type = z_HTTP_header_lookup(hreq->headers, + "Content-Type"); + /* + SRU GET: allow any content type. + SRU POST: we support "application/x-www-form-urlencoded"; + not "multipart/form-data" . + */ + if (!strcmp(hreq->method, "GET") + || + (!strcmp(hreq->method, "POST") + && content_type && + !yaz_strcmp_del("application/x-www-form-urlencoded", + content_type, "; ") + ) + ) { char *db = "Default"; const char *p0 = hreq->path, *p1;