* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zgdu.c,v 1.13 2005-06-25 15:46:06 adam Exp $
+ * $Id: zgdu.c,v 1.15 2006-06-02 13:08:27 adam Exp $
*/
/**
return 1;
}
+void z_HTTP_header_add_content_type(ODR o, Z_HTTP_Header **hp,
+ const char *content_type,
+ const char *charset)
+{
+ const char *l = "Content-Type";
+ if (charset)
+ {
+ char *ctype = odr_malloc(o, strlen(content_type)+strlen(charset) + 15);
+ sprintf(ctype, "%s; charset=%s", content_type, charset);
+ z_HTTP_header_add(o, hp, l, ctype);
+ }
+ else
+ z_HTTP_header_add(o, hp, l, content_type);
+
+}
+
void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n,
const char *v)
{
return p;
}
+
+Z_GDU *z_get_HTTP_Request_host_path(ODR odr,
+ const char *host,
+ const char *path)
+{
+ Z_GDU *p = z_get_HTTP_Request(odr);
+
+ p->u.HTTP_Request->path = odr_strdup(odr, path);
+
+ if (host)
+ {
+ const char *cp0 = strstr(host, "://");
+ const char *cp1 = 0;
+ if (cp0)
+ cp0 = cp0+3;
+ else
+ cp0 = host;
+
+ 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);
+ }
+ }
+ return p;
+}
+
+
Z_GDU *z_get_HTTP_Response(ODR o, int code)
{
Z_GDU *p = (Z_GDU *) odr_malloc(o, sizeof(*p));