Lines Matching refs:conn
119 conn_t *conn; /* connection */
142 if (_fetch_getln(io->conn) == -1)
145 if (io->conn->buflen < 2 || !ishexnumber((unsigned)*io->conn->buf))
148 for (p = io->conn->buf; *p && !isspace((unsigned)*p); ++p) {
209 if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) {
232 if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) {
241 if (_fetch_read(io->conn, endl, 2) != 2 ||
290 return (_fetch_write(io->conn, buf, (unsigned) len));
302 r = _fetch_close(io->conn);
313 _http_funopen(conn_t *conn, int chunked)
322 io->conn = conn;
370 _http_cmd(conn_t *conn, const char *fmt, ...)
387 r = _fetch_putln(conn, msg, len);
402 _http_get_reply(conn_t *conn)
406 if (_fetch_getln(conn) == -1)
417 if (strncmp(conn->buf, "HTTP", 4) != 0)
419 p = conn->buf + 4;
428 conn->err = (p[1] - '0') * 100 + (p[2] - '0') * 10 + (p[3] - '0');
429 return (conn->err);
452 _http_next_header(conn_t *conn, const char **p)
456 if (_fetch_getln(conn) == -1)
458 while (conn->buflen && isspace((unsigned)conn->buf[conn->buflen - 1]))
459 conn->buflen--;
460 conn->buf[conn->buflen] = '\0';
461 if (conn->buflen == 0)
470 if ((*p = _http_match(hdr_names[i].name, conn->buf)) != NULL)
625 _http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd)
638 r = _http_cmd(conn, "%s: Basic %s", hdr, auth);
647 _http_authorize(conn_t *conn, const char *hdr, const char *p)
664 r = _http_basic_auth(conn, hdr, user, pwd);
682 conn_t *conn;
708 if ((conn = _fetch_connect(URL->host, URL->port, af, verbose)) == NULL)
712 _fetch_ssl(conn, verbose) == -1) {
713 _fetch_close(conn);
725 setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val));
729 return (conn);
806 conn_t *conn;
857 if ((conn = _http_connect(url, purl, flags)) == NULL)
881 _http_cmd(conn, "%s %s://%s%s HTTP/1.1",
884 _http_cmd(conn, "%s %s HTTP/1.1",
889 _http_cmd(conn, "Host: %s", host);
894 _http_basic_auth(conn, "Proxy-Authorization",
897 _http_authorize(conn, "Proxy-Authorization", p);
903 _http_basic_auth(conn, "Authorization", url->user, url->pwd);
905 _http_authorize(conn, "Authorization", p);
907 _http_basic_auth(conn, "Authorization", url->user, url->pwd);
917 _http_cmd(conn, "Referer: %s://%s%s",
920 _http_cmd(conn, "Referer: %s", p);
923 _http_cmd(conn, "User-Agent: %s", p);
925 _http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
927 _http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
928 _http_cmd(conn, "Connection: close");
929 _http_cmd(conn, "");
940 setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val,
944 setsockopt(conn->sd, IPPROTO_TCP, TCP_NODELAY, &val,
948 switch (_http_get_reply(conn)) {
967 _http_seterr(conn->err);
980 _http_seterr(conn->err);
995 _http_seterr(conn->err);
1003 switch ((h = _http_next_header(conn, &p))) {
1020 if (!HTTP_REDIRECT(conn->err))
1025 _fetch_info("%d redirect to %s", conn->err, p);
1049 if (conn->err != HTTP_NEED_AUTH)
1062 if (conn->err == HTTP_NEED_AUTH) {
1063 e = conn->err;
1065 _fetch_close(conn);
1066 conn = NULL;
1071 if (conn->err == HTTP_BAD_RANGE) {
1075 conn->err = HTTP_OK;
1078 _http_seterr(conn->err);
1084 if (conn->err == HTTP_OK || conn->err == HTTP_PARTIAL || HTTP_ERROR(conn->err))
1088 e = conn->err;
1090 _fetch_close(conn);
1091 conn = NULL;
1102 if (conn == NULL) {
1145 if ((f = _http_funopen(conn, chunked)) == NULL) {
1155 if (HTTP_ERROR(conn->err)) {
1168 if (conn != NULL)
1169 _fetch_close(conn);