out = fdopen(fd, "w");
fprintf(out, "HTTP/1.1 %i %s\r\n", code, msg);
fprintf(out, "Content-Type: text/html\r\n");
- fprintf(out, "Content-Length: %i\r\n", buf.d);
+ fprintf(out, "Content-Length: %zi\r\n", buf.d);
fprintf(out, "\r\n");
fwrite(buf.b, 1, buf.d, out);
fclose(out);
char buf[8192];
total = 0;
- while(!feof(in) && (total < max)) {
+ while(!feof(in) && ((max < 0) || (total < max))) {
read = sizeof(buf);
if(max >= 0)
read = min(max - total, read);
read = fread(buf, 1, sizeof(buf), in);
if(ferror(in))
return(-1);
- fprintf(out, "%x\r\n", read);
+ fprintf(out, "%zx\r\n", read);
if(fwrite(buf, 1, read, out) != read)
return(-1);
fprintf(out, "\r\n");
/* Make sure to send EOF */
shutdown(pfds[1], SHUT_WR);
- resp = parseresp(out);
+ if((resp = parseresp(out)) == NULL)
+ break;
replstr(&resp->ver, req->ver);
if(!strcmp(req->ver, "HTTP/1.0")) {