#include <config.h>
#endif
-#include <ctype.h>
#include <yaz/odr.h>
#include <yaz/yaz-version.h>
#include <yaz/yaz-iconv.h>
/* chunk length .. */
int chunk_len = 0;
for (; i < o->size-2; i++)
- if (isdigit(o->buf[i]))
+ if (yaz_isdigit(o->buf[i]))
chunk_len = chunk_len * 16 +
(o->buf[i] - '0');
- else if (isupper(o->buf[i]))
+ else if (yaz_isupper(o->buf[i]))
chunk_len = chunk_len * 16 +
(o->buf[i] - ('A'-10));
- else if (islower(o->buf[i]))
+ else if (yaz_islower(o->buf[i]))
chunk_len = chunk_len * 16 +
(o->buf[i] - ('a'-10));
else
if (username == 0)
return;
+ if (password == 0)
+ password = "";
len = strlen(username) + strlen(password);
tmp = (char *) odr_malloc(o, len+2);
return p;
}
+Z_GDU *z_get_HTTP_Request_uri(ODR odr, const char *uri, const char *args,
+ int use_full_uri)
+{
+ Z_GDU *p = z_get_HTTP_Request(odr);
+ const char *cp0 = strstr(uri, "://");
+ const char *cp1 = 0;
+ if (cp0)
+ cp0 = cp0+3;
+ else
+ cp0 = uri;
+
+ cp1 = strchr(cp0, '/');
+ if (!cp1)
+ cp1 = cp0+strlen(cp0);
+
+ if (cp0 && cp1)
+ {
+ char *h = (char*) odr_malloc(odr, cp1 - cp0 + 1);
+ memcpy (h, cp0, cp1 - cp0);
+ h[cp1-cp0] = '\0';
+ z_HTTP_header_add(odr, &p->u.HTTP_Request->headers,
+ "Host", h);
+ }
+
+ if (!args)
+ {
+ if (*cp1)
+ args = cp1 + 1;
+ else
+ args = "";
+ }
+ p->u.HTTP_Request->path = odr_malloc(odr, cp1 - uri + strlen(args) + 2);
+ if (use_full_uri)
+ {
+ memcpy(p->u.HTTP_Request->path, uri, cp1 - uri);
+ strcpy(p->u.HTTP_Request->path + (cp1 - uri), "/");
+ }
+ else
+ strcpy(p->u.HTTP_Request->path, "/");
+ strcat(p->u.HTTP_Request->path, args);
+ return p;
+}
Z_GDU *z_get_HTTP_Response(ODR o, int code)
{