X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp.c;h=0fdd465907b00d565edcaa346e60d87a8d06b3f7;hb=20c28e99eaa71d4b73e8c03c8cfaf23653948da7;hp=0f17df533b598e5f505330ec4795afbb1d04e0ef;hpb=d606d0d7c6015414a1d5ba065d09b507679be5a3;p=yaz-moved-to-github.git diff --git a/src/http.c b/src/http.c index 0f17df5..0fdd465 100644 --- a/src/http.c +++ b/src/http.c @@ -511,6 +511,12 @@ int yaz_decode_http_request(ODR o, Z_HTTP_Request **hr_p) int lspace = 0; *hr_p = hr; + hr->method = 0; + hr->version = 0; + hr->path = 0; + hr->headers = 0; + hr->content_buf = 0; + hr->content_len = 0; /* method .. */ for (i = 0; buf[i] != ' '; i++) if (i >= size-5 || i > 30) @@ -610,11 +616,15 @@ int yaz_encode_http_response(ODR o, Z_HTTP_Response *hr) int yaz_encode_http_request(ODR o, Z_HTTP_Request *hr) { Z_HTTP_Header *h; + char *cp; int top0 = o->op->top; + if (!hr->method || !hr->path) + return 0; odr_write(o, hr->method, strlen(hr->method)); odr_write(o, " ", 1); - odr_write(o, hr->path, strlen(hr->path)); + cp = strchr(hr->path, '#'); + odr_write(o, hr->path, cp ? (cp - hr->path) : strlen(hr->path)); odr_write(o, " HTTP/", 6); odr_write(o, hr->version, strlen(hr->version)); odr_write(o, "\r\n", 2);