From ba4e41500638f489cc346f582ba73f8bf523256a Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 26 Nov 2014 12:04:29 +0800 Subject: [PATCH] clean test server a bit Signed-off-by: Andy Green --- test-server/test-server.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/test-server/test-server.c b/test-server/test-server.c index 6183117..97493cc 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -154,10 +154,6 @@ static int callback_http(struct libwebsocket_context *context, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { -#if 0 - char client_name[128]; - char client_ip[128]; -#endif char buf[256]; char leaf_path[1024]; char b64[64]; @@ -230,11 +226,18 @@ static int callback_http(struct libwebsocket_context *context, */ if (lws_add_http_header_status(context, wsi, 200, &p, end)) return 1; - if (lws_add_http_header_by_token(context, wsi, WSI_TOKEN_HTTP_SERVER, (unsigned char *)"libwebsockets", 13, &p, end)) + if (lws_add_http_header_by_token(context, wsi, + WSI_TOKEN_HTTP_SERVER, + (unsigned char *)"libwebsockets", + 13, &p, end)) return 1; - if (lws_add_http_header_by_token(context, wsi, WSI_TOKEN_HTTP_CONTENT_TYPE, (unsigned char *)"image/jpeg", 10, &p, end)) + if (lws_add_http_header_by_token(context, wsi, + WSI_TOKEN_HTTP_CONTENT_TYPE, + (unsigned char *)"image/jpeg", + 10, &p, end)) return 1; - if (lws_add_http_header_content_length(context, wsi,stat_buf.st_size, &p, end)) + if (lws_add_http_header_content_length(context, wsi, + stat_buf.st_size, &p, end)) return 1; if (lws_finalize_http_header(context, wsi, &p, end)) return 1; @@ -251,9 +254,9 @@ static int callback_http(struct libwebsocket_context *context, */ n = libwebsocket_write(wsi, - buffer + LWS_SEND_BUFFER_PRE_PADDING, - p - (buffer + LWS_SEND_BUFFER_PRE_PADDING), - LWS_WRITE_HTTP_HEADERS); + buffer + LWS_SEND_BUFFER_PRE_PADDING, + p - (buffer + LWS_SEND_BUFFER_PRE_PADDING), + LWS_WRITE_HTTP_HEADERS); if (n < 0) { close(pss->fd); @@ -428,13 +431,7 @@ bail: */ case LWS_CALLBACK_FILTER_NETWORK_CONNECTION: -#if 0 - libwebsockets_get_peer_addresses(context, wsi, (int)(long)in, client_name, - sizeof(client_name), client_ip, sizeof(client_ip)); - fprintf(stderr, "Received network connect from %s (%s)\n", - client_name, client_ip); -#endif /* if we returned non-zero from here, we kill the connection */ break; -- 2.7.4