diff options
Diffstat (limited to 'package/uhttpd/src/uhttpd-utils.c')
-rw-r--r-- | package/uhttpd/src/uhttpd-utils.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/package/uhttpd/src/uhttpd-utils.c b/package/uhttpd/src/uhttpd-utils.c index 50b10e6050..c8d3bb40f4 100644 --- a/package/uhttpd/src/uhttpd-utils.c +++ b/package/uhttpd/src/uhttpd-utils.c @@ -334,7 +334,7 @@ int uh_http_sendf(struct client *cl, struct http_request *req, len = vsnprintf(buffer, sizeof(buffer), fmt, ap); va_end(ap); - if ((req != NULL) && (req->version > 1.0)) + if ((req != NULL) && (req->version > UH_HTTP_VER_1_0)) ensure_ret(uh_http_sendc(cl, buffer, len)); else if (len > 0) ensure_ret(uh_tcp_send(cl, buffer, len)); @@ -348,7 +348,7 @@ int uh_http_send(struct client *cl, struct http_request *req, if (len < 0) len = strlen(buf); - if ((req != NULL) && (req->version > 1.0)) + if ((req != NULL) && (req->version > UH_HTTP_VER_1_0)) ensure_ret(uh_http_sendc(cl, buf, len)); else if (len > 0) ensure_ret(uh_tcp_send(cl, buf, len)); @@ -865,13 +865,13 @@ int uh_auth_check(struct client *cl, struct http_request *req, /* 401 */ uh_http_sendf(cl, NULL, - "HTTP/%.1f 401 Authorization Required\r\n" - "WWW-Authenticate: Basic realm=\"%s\"\r\n" - "Content-Type: text/plain\r\n" - "Content-Length: 23\r\n\r\n" - "Authorization Required\n", - req->version, cl->server->conf->realm - ); + "%s 401 Authorization Required\r\n" + "WWW-Authenticate: Basic realm=\"%s\"\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 23\r\n\r\n" + "Authorization Required\n", + http_versions[req->version], + cl->server->conf->realm); return 0; } @@ -922,7 +922,8 @@ struct listener * uh_listener_lookup(int sock) } -struct client * uh_client_add(int sock, struct listener *serv) +struct client * uh_client_add(int sock, struct listener *serv, + struct sockaddr_in6 *peer) { struct client *new = NULL; socklen_t sl; @@ -930,6 +931,7 @@ struct client * uh_client_add(int sock, struct listener *serv) if ((new = (struct client *)malloc(sizeof(struct client))) != NULL) { memset(new, 0, sizeof(struct client)); + memcpy(&new->peeraddr, peer, sizeof(new->peeraddr)); new->fd.fd = sock; new->server = serv; @@ -937,14 +939,8 @@ struct client * uh_client_add(int sock, struct listener *serv) new->rpipe.fd = -1; new->wpipe.fd = -1; - /* get remote endpoint addr */ - sl = sizeof(struct sockaddr_in6); - memset(&(new->peeraddr), 0, sl); - getpeername(sock, (struct sockaddr *) &(new->peeraddr), &sl); - /* get local endpoint addr */ sl = sizeof(struct sockaddr_in6); - memset(&(new->servaddr), 0, sl); getsockname(sock, (struct sockaddr *) &(new->servaddr), &sl); new->next = uh_clients; @@ -988,7 +984,7 @@ void uh_client_remove(struct client *cl) for (cur = uh_clients; cur; prv = cur, cur = cur->next) { - if ((cur == cl) || (!cl && cur->dead)) + if (cur == cl) { if (prv) prv->next = cur->next; |