Z_HTTP_Response *hres = gdu->u.HTTP_Response;
hres->content_len = sz;
- hres->content_buf = (char*) odr_malloc(o, hres->content_len);
- if (fread(hres->content_buf, hres->content_len, 1, f) != 1)
+ if (hres->content_len > 0)
{
- fclose(f);
- Z_GDU *gdu = o.create_HTTP_Response(session, req, 500);
- package.response() = gdu;
- return;
+ hres->content_buf = (char*) odr_malloc(o, hres->content_len);
+ if (fread(hres->content_buf, hres->content_len, 1, f) != 1)
+ {
+ fclose(f);
+ Z_GDU *gdu = o.create_HTTP_Response(session, req, 500);
+ package.response() = gdu;
+ return;
+ }
}
-
fclose(f);
std::string content_type = get_mime_type(fname);