Lines Matching +full:buffered +full:- +full:positive
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
64 * Base64 encode a string; the string returned, if non-NULL, is
81 * Encoded length is 4 characters per 3-byte block or partial in b64enc()
85 if (ptlen > ((SIZE_MAX - 1) / 4) * 3 - 2) in b64enc()
90 ctext[ctlen - 1] = 0; in b64enc()
96 for (pt = ptext, pc = ctext; ptlen; ptlen -= 3, pc += 4) { in b64enc()
171 asprintf(&proxyauth, "Proxy-Authorization: Basic %s\r\n", in readenv()
190 warnx("HTTP_TIMEOUT (%s) is not a positive integer", in readenv()
205 "User-Agent: %s\r\n" in makerequest()
213 connclose ? "Connection: Close\r\n" : "Connection: Keep-Alive\r\n"); in makerequest()
214 if (buflen == -1) in makerequest()
225 *resbuflen - *resbufpos) == NULL) { in readln()
226 /* Move buffered data to the start of the buffer */ in readln()
229 *resbuflen - *resbufpos); in readln()
230 *resbuflen -= *resbufpos; in readln()
236 return -1; in readln()
239 len = recv(sd, resbuf + *resbuflen, BUFSIZ - *resbuflen, 0); in readln()
241 ((len == -1) && (errno != EINTR))) in readln()
242 return -1; in readln()
244 if (len != -1) in readln()
259 len = *resbuflen - *resbufpos; in copybytes()
263 if (fd != -1) in copybytes()
265 if (len == -1) in copybytes()
268 copylen -= len; in copybytes()
274 if (len == -1) { in copybytes()
277 return -1; in copybytes()
279 return -2; in copybytes()
309 int keepalive; /* != 0 if HTTP/1.0 keep-alive rcvd. */ in main()
310 int sd = -1; /* Socket descriptor */ in main()
312 int fd = -1; /* Descriptor for download target file */ in main()
315 off_t contentlength; /* Value from Content-Length header */ in main()
316 int chunked; /* != if transfer-encoding is chunked */ in main()
331 argc -= 2; in main()
356 for (; sd == -1; res = res->ai_next) { in main()
357 /* No addresses left to try :-( */ in main()
362 sd = socket(res->ai_family, res->ai_socktype, in main()
363 res->ai_protocol); in main()
364 if (sd == -1) in main()
367 /* ... set 15-second timeouts ... */ in main()
379 if(connect(sd, res->ai_addr, res->ai_addrlen)) { in main()
381 sd = -1; in main()
389 * If in pipelined HTTP mode, put socket into non-blocking in main()
395 if (fcntl(sd, F_SETFL, sdflags | O_NONBLOCK) == -1) in main()
404 servername, (nreq == argc - 1)); in main()
412 reqbuflen - reqbufpos, 0); in main()
413 if (len == -1) in main()
431 if (fcntl(sd, F_SETFL, sdflags) == -1) in main()
435 /* Do we need to blocking-send a request? */ in main()
439 reqbuflen - reqbufpos, 0); in main()
440 if (len == -1) in main()
451 contentlength = -1; in main()
460 eolp = strnstr(hln, "\r\n", resbuflen - resbufpos); in main()
461 resbufpos = (eolp - resbuf) + 2; in main()
477 * requests is OK -- as long as we don't in main()
479 * and we either have a Content-Length or in main()
480 * Transfer-Encoding: chunked header to in main()
496 *hln - '0'; in main()
509 * "Connection: Keep-Alive" header in main()
515 if (strcasestr(hln, "Keep-Alive") != NULL) in main()
522 /* Check for "Content-Length:" header */ in main()
523 if (strncasecmp(hln, "Content-Length:", 15) == 0) { in main()
538 *hln - '0'; in main()
546 /* Check for "Transfer-Encoding: chunked" header */ in main()
547 if (strncasecmp(hln, "Transfer-Encoding:", 18) == 0) { in main()
598 if (fd == -1) in main()
604 /* Handle a chunked-encoded entity */ in main()
614 resbufpos = (eolp - resbuf) + 2; in main()
623 clen = clen * 16 + *hln - '0'; in main()
626 tolower(*hln) - 'a'; in main()
645 resbufpos = (eolp - resbuf) + 2; in main()
647 } else if (contentlength != -1) { in main()
660 if (error == -1) in main()
665 if (fd != -1) { in main()
667 fd = -1; in main()
694 * Something went wrong -- our connection died, the server in main()
709 sd = -1; in main()
710 if (fd != -1) { in main()
712 fd = -1; in main()