* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: zgdu.c,v 1.1 2003-10-27 12:21:36 adam Exp $
+ * $Id: zgdu.c,v 1.5 2003-12-31 00:14:01 adam Exp $
*/
#include <yaz/odr.h>
#include <yaz/yaz-version.h>
+#include <yaz/yaz-iconv.h>
#include <yaz/zgdu.h>
static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
const char *z_HTTP_header_lookup(Z_HTTP_Header *hp, const char *n)
{
for (; hp; hp = hp->next)
- if (!strcmp(hp->name, n))
+ if (!yaz_matchstr(hp->name, n))
return hp->value;
return 0;
}
if (!z_HTTP_header_lookup((*p)->u.HTTP_Response->headers,
"Content-Length"))
{
- char lstr[20];
- sprintf(lstr, "%d", (*p)->u.HTTP_Response->content_len);
- z_HTTP_header_add(o,
- &(*p)->u.HTTP_Response->headers,
- "Content-Length", lstr);
+ char lstr[60];
+ sprintf(lstr, "Content-Length: %d\r\n",
+ (*p)->u.HTTP_Response->content_len);
+ odr_write(o, (unsigned char *) lstr, strlen(lstr));
}
for (h = (*p)->u.HTTP_Response->headers; h; h = h->next)
{
!z_HTTP_header_lookup((*p)->u.HTTP_Request->headers,
"Content-Length"))
{
- char lstr[20];
- sprintf(lstr, "%d", (*p)->u.HTTP_Request->content_len);
- z_HTTP_header_add(o,
- &(*p)->u.HTTP_Request->headers,
- "Content-Length", lstr);
+ char lstr[60];
+ sprintf(lstr, "Content-Length: %d\r\n",
+ (*p)->u.HTTP_Request->content_len);
+ odr_write(o, (unsigned char *) lstr, strlen(lstr));
}
for (h = (*p)->u.HTTP_Request->headers; h; h = h->next)
{
(*p)->u.HTTP_Request->content_len);
if (o->direction == ODR_PRINT)
{
- fprintf(o->print, "-- HTTP request:\n%.*s\n", o->top, o->buf);
+ fprintf(o->print, "-- HTTP request:\n%.*s\n", o->top - top0,
+ o->buf + top0);
+ fprintf(o->print, "-- \n");
}
break;
case Z_GDU_Z3950: