- if (hc->status == HTTP_READY_TO_STREAM) {
- size_t hlen;
- char *hbuf = vss_get_header(&hlen);
- if (hbuf && hlen > 0 && current_chunk) {
- /* need to send header */
- PARA_INFO_LOG("queueing header: %zu\n", hlen);
- if (queue_chunk_or_shutdown(hc, -1U, 0) < 0)
- continue;
- } else
- PARA_INFO_LOG("no need to queue header\n");
- hc->status = HTTP_STREAMING;
- }
- ret = send_queued_chunks(hc);
- if (ret < 0) {
- http_shutdown_client(hc, "queue send error");
- continue;
- }
- if (!len)
- continue;
- if (!ret || write_ok(hc->fd) <= 0) {
- queue_chunk_or_shutdown(hc, current_chunk, 0);
- continue;
- }
-// PARA_DEBUG_LOG("sending %d -> %s\n", len, remote_name(hc->fd));
- ret = write(hc->fd, buf, len);
-// PARA_DEBUG_LOG("ret: %d\n", ret);
- if (ret < 0) {
- http_shutdown_client(hc, "send error");
- continue;
- }
- if (ret != len)
- queue_chunk_or_shutdown(hc, current_chunk, ret);
- }
-}
-
-/**
- * Return true if addr_1 matches addr_2 in the first `netmask' bits.
- */
-static int v4_addr_match(uint32_t addr_1, uint32_t addr_2, uint8_t netmask)
-{
- uint32_t mask = ~0U;
-
- if (netmask < 32)
- mask <<= (32 - netmask);
- return (htonl(addr_1) & mask) == (htonl(addr_2) & mask);
-}
-
-static int host_in_access_perm_list(struct http_client *hc)
-{
- struct access_info *ai, *tmp;
- struct sockaddr_storage ss;
- socklen_t sslen = sizeof(ss);
- struct in_addr v4_addr;
-
- if (getpeername(hc->fd, (struct sockaddr *)&ss, &sslen) < 0) {
- PARA_ERROR_LOG("Can not determine peer address: %s\n", strerror(errno));
- goto no_match;