mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
[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@32704 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user