summaryrefslogtreecommitdiff
path: root/uhttpd-utils.c
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-07-13 17:10:56 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-07-13 17:10:56 +0000
commit46c0115361b8e63a74814b90b165e5fcb2ce284d (patch)
tree490d5893ef4ee299dc177dc9bb5c10ac3eb160ea /uhttpd-utils.c
parent945edd6c0c9e6bd1ad4daa4cc204f5ca283b81b5 (diff)
downloaduhttpd-46c0115361b8e63a74814b90b165e5fcb2ce284d.tar.gz
[package] uhttpd: various changes
- remove unused variables - simply ignore command line args which belong to not enabled features - resolve peer address at accept() time, should solve (#11850) - remove floating point operations where possible git-svn-id: svn://svn.openwrt.org/openwrt/trunk/package/uhttpd/src@32704 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'uhttpd-utils.c')
-rw-r--r--uhttpd-utils.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/uhttpd-utils.c b/uhttpd-utils.c
index 50b10e6..c8d3bb4 100644
--- a/uhttpd-utils.c
+++ b/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;