X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzgdu.c;h=543eda6d387ebd2d3797367d27aaae6f21bbae2a;hb=97554b23cfc19394bb77f7f3c4bf0c8abf89297b;hp=a37a96e7221a32ac6c3b0386e2fb801c34624b87;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9;p=yaz-moved-to-github.git diff --git a/src/zgdu.c b/src/zgdu.c index a37a96e..543eda6 100644 --- a/src/zgdu.c +++ b/src/zgdu.c @@ -2,11 +2,12 @@ * 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 #include +#include #include static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers, @@ -96,7 +97,7 @@ void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n, 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; } @@ -293,11 +294,10 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) 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) { @@ -332,11 +332,10 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) !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) { @@ -352,7 +351,9 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) (*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: