#include <netinet/tcp.h>
#include <malloc.h>
#include <pwd.h>
+#include <ctype.h>
#include "common.h"
#include "log.h"
int web_client_timeout = DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS;
int web_enable_gzip = 1;
+extern int netdata_exit;
+
struct web_client *web_clients = NULL;
unsigned long long web_clients_count = 0;
struct web_client *web_client_create(int listener)
{
struct web_client *w;
-
+
w = calloc(1, sizeof(struct web_client));
if(!w) {
error("Cannot allocate new web_client memory.");
if(w == web_clients) web_clients = w->next;
+ if(w->response.header_output) buffer_free(w->response.header_output);
if(w->response.header) buffer_free(w->response.header);
if(w->response.data) buffer_free(w->response.data);
close(w->ifd);
else {
struct passwd *pw = getpwnam(web_owner);
if(!pw) {
- error("User %s is not present. Ignoring option. Error: %s\n", web_owner, strerror(errno));
+ error("User %s is not present. Ignoring option.", web_owner);
owner_uid = geteuid();
}
else {
else if(strstr(filename, ".svg") != NULL) w->response.data->contenttype = CT_IMAGE_SVG_XML;
else if(strstr(filename, ".ttf") != NULL) w->response.data->contenttype = CT_APPLICATION_X_FONT_TRUETYPE;
else if(strstr(filename, ".otf") != NULL) w->response.data->contenttype = CT_APPLICATION_X_FONT_OPENTYPE;
+ else if(strstr(filename, ".woff2")!= NULL) w->response.data->contenttype = CT_APPLICATION_FONT_WOFF2;
else if(strstr(filename, ".woff") != NULL) w->response.data->contenttype = CT_APPLICATION_FONT_WOFF;
else if(strstr(filename, ".eot") != NULL) w->response.data->contenttype = CT_APPLICATION_VND_MS_FONTOBJ;
else w->response.data->contenttype = CT_APPLICATION_OCTET_STREAM;
}
#endif // NETDATA_WITH_ZLIB
-int rrdset_validate_dimensions(RRDSET *st, BUFFER *dimensions)
+uint32_t web_client_api_request_v1_data_options(char *o)
{
- ;
+ uint32_t ret = 0x00000000;
+ char *tok;
+
+ while(o && *o && (tok = mystrsep(&o, ", |"))) {
+ if(!*tok) continue;
+
+ if(!strcmp(tok, "nonzero"))
+ ret |= RRDR_OPTION_NONZERO;
+ else if(!strcmp(tok, "flip") || !strcmp(tok, "reversed") || !strcmp(tok, "reverse"))
+ ret |= RRDR_OPTION_REVERSED;
+ else if(!strcmp(tok, "jsonwrap"))
+ ret |= RRDR_OPTION_JSON_WRAP;
+ else if(!strcmp(tok, "min2max"))
+ ret |= RRDR_OPTION_MIN2MAX;
+ else if(!strcmp(tok, "ms") || !strcmp(tok, "milliseconds"))
+ ret |= RRDR_OPTION_MILLISECONDS;
+ else if(!strcmp(tok, "abs") || !strcmp(tok, "absolute") || !strcmp(tok, "absolute_sum") || !strcmp(tok, "absolute-sum"))
+ ret |= RRDR_OPTION_ABSOLUTE;
+ else if(!strcmp(tok, "seconds"))
+ ret |= RRDR_OPTION_SECONDS;
+ else if(!strcmp(tok, "null2zero"))
+ ret |= RRDR_OPTION_NULL2ZERO;
+ else if(!strcmp(tok, "objectrows"))
+ ret |= RRDR_OPTION_OBJECTSROWS;
+ else if(!strcmp(tok, "google_json"))
+ ret |= RRDR_OPTION_GOOGLE_JSON;
+ }
+
+ return ret;
}
-int web_client_api_request_v1_data_format(char *name)
+uint32_t web_client_api_request_v1_data_format(char *name)
{
- if(!strcmp(name, "datatable"))
- return DATASOURCE_GOOGLE_JSON;
+ if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSON)) // datatable
+ return DATASOURCE_DATATABLE_JSON;
- else if(!strcmp(name, "datasource"))
- return DATASOURCE_GOOGLE_JSONP;
+ else if(!strcmp(name, DATASOURCE_FORMAT_DATATABLE_JSONP)) // datasource
+ return DATASOURCE_DATATABLE_JSONP;
- else if(!strcmp(name, "json"))
+ else if(!strcmp(name, DATASOURCE_FORMAT_JSON)) // json
return DATASOURCE_JSON;
- else if(!strcmp(name, "ssv"))
+ else if(!strcmp(name, DATASOURCE_FORMAT_JSONP)) // jsonp
+ return DATASOURCE_JSONP;
+
+ else if(!strcmp(name, DATASOURCE_FORMAT_SSV)) // ssv
return DATASOURCE_SSV;
+ else if(!strcmp(name, DATASOURCE_FORMAT_CSV)) // csv
+ return DATASOURCE_CSV;
+
+ else if(!strcmp(name, DATASOURCE_FORMAT_TSV) || !strcmp(name, "tsv-excel")) // tsv
+ return DATASOURCE_TSV;
+
+ else if(!strcmp(name, DATASOURCE_FORMAT_HTML)) // html
+ return DATASOURCE_HTML;
+
+ else if(!strcmp(name, DATASOURCE_FORMAT_JS_ARRAY)) // array
+ return DATASOURCE_JS_ARRAY;
+
+ else if(!strcmp(name, DATASOURCE_FORMAT_SSV_COMMA)) // ssvcomma
+ return DATASOURCE_SSV_COMMA;
+
+ return DATASOURCE_JSON;
+}
+
+uint32_t web_client_api_request_v1_data_google_format(char *name)
+{
+ if(!strcmp(name, "json"))
+ return DATASOURCE_DATATABLE_JSONP;
+
+ else if(!strcmp(name, "html"))
+ return DATASOURCE_HTML;
+
else if(!strcmp(name, "csv"))
return DATASOURCE_CSV;
- return DATASOURCE_INVALID;
+ else if(!strcmp(name, "tsv-excel"))
+ return DATASOURCE_TSV;
+
+ return DATASOURCE_JSON;
+}
+
+int web_client_api_request_v1_data_group(char *name)
+{
+ if(!strcmp(name, "max"))
+ return GROUP_MAX;
+
+ else if(!strcmp(name, "average"))
+ return GROUP_AVERAGE;
+
+ return GROUP_MAX;
}
int web_client_api_request_v1_charts(struct web_client *w, char *url)
{
+ if(url) { ; }
+
buffer_flush(w->response.data);
+ w->response.data->contenttype = CT_APPLICATION_JSON;
rrd_stats_api_v1_charts(w->response.data);
return 200;
}
// they are not null and not empty
if(!strcmp(name, "chart")) chart = value;
- else {
- buffer_sprintf(w->response.data, "Unknown parameter '%s' in request.", name);
- goto cleanup;
- }
+ //else {
+ /// buffer_sprintf(w->response.data, "Unknown parameter '%s' in request.", name);
+ // goto cleanup;
+ //}
}
if(!chart || !*chart) {
return ret;
}
+// returns the HTTP code
int web_client_api_request_v1_data(struct web_client *w, char *url)
{
+ debug(D_WEB_CLIENT, "%llu: API v1 data with URL '%s'", w->id, url);
+
int ret = 400;
BUFFER *dimensions = NULL;
buffer_flush(w->response.data);
+ char *google_version = "0.6",
+ *google_reqId = "0",
+ *google_sig = "0",
+ *google_out = "json",
+ *responseHandler = NULL,
+ *outFileName = NULL;
+
+ time_t last_timestamp_in_data = 0, google_timestamp = 0;
+
char *chart = NULL
- , *dim = NULL
, *before_str = NULL
, *after_str = NULL
- , *points_str = NULL
- , *group_str = NULL
- , *options = NULL;
+ , *points_str = NULL;
- int format = DATASOURCE_JSON;
+ int group = GROUP_MAX;
+ uint32_t format = DATASOURCE_JSON;
+ uint32_t options = 0x00000000;
while(url) {
char *value = mystrsep(&url, "?&[]");
if(!name || !*name) continue;
if(!value || !*value) continue;
+ debug(D_WEB_CLIENT, "%llu: API v1 query param '%s' with value '%s'", w->id, name, value);
+
// name and value are now the parameters
// they are not null and not empty
if(!strcmp(name, "chart")) chart = value;
- else if(!strcmp(name, "dimension") || !strcmp(name, "dim")) {
+ else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
if(!dimensions) dimensions = buffer_create(strlen(value));
if(dimensions) {
buffer_strcat(dimensions, "|");
else if(!strcmp(name, "after")) after_str = value;
else if(!strcmp(name, "before")) before_str = value;
else if(!strcmp(name, "points")) points_str = value;
- else if(!strcmp(name, "group")) group_str = value;
+ else if(!strcmp(name, "group")) {
+ group = web_client_api_request_v1_data_group(value);
+ }
else if(!strcmp(name, "format")) {
format = web_client_api_request_v1_data_format(value);
}
else if(!strcmp(name, "options")) {
- options = value;
+ options |= web_client_api_request_v1_data_options(value);
}
- else {
- buffer_sprintf(w->response.data, "Unknown parameter '%s' in request.", name);
- goto cleanup;
+ else if(!strcmp(name, "callback")) {
+ responseHandler = value;
+ }
+ else if(!strcmp(name, "filename")) {
+ outFileName = value;
+ }
+ else if(!strcmp(name, "tqx")) {
+ // parse Google Visualization API options
+ // https://developers.google.com/chart/interactive/docs/dev/implementing_data_source
+ char *tqx_name, *tqx_value;
+
+ while(value) {
+ tqx_value = mystrsep(&value, ";");
+ if(!tqx_value || !*tqx_value) continue;
+
+ tqx_name = mystrsep(&tqx_value, ":");
+ if(!tqx_name || !*tqx_name) continue;
+ if(!tqx_value || !*tqx_value) continue;
+
+ if(!strcmp(tqx_name, "version"))
+ google_version = tqx_value;
+ else if(!strcmp(tqx_name, "reqId"))
+ google_reqId = tqx_value;
+ else if(!strcmp(tqx_name, "sig")) {
+ google_sig = tqx_value;
+ google_timestamp = strtoul(google_sig, NULL, 0);
+ }
+ else if(!strcmp(tqx_name, "out")) {
+ google_out = tqx_value;
+ format = web_client_api_request_v1_data_google_format(google_out);
+ }
+ else if(!strcmp(tqx_name, "responseHandler"))
+ responseHandler = tqx_value;
+ else if(!strcmp(tqx_name, "outFileName"))
+ outFileName = tqx_value;
+ }
}
}
goto cleanup;
}
- uint32_t before = (before_str && *before_str)?atol(before_str):0;
- uint32_t after = (after_str && *after_str) ?atol(after_str):0;
- int points = (points_str && *points_str)?atoi(points_str):0;
- int group = (group_str && *group_str) ?atoi(group_str):0;
+ long long before = (before_str && *before_str)?atol(before_str):0;
+ long long after = (after_str && *after_str) ?atol(after_str):0;
+ int points = (points_str && *points_str)?atoi(points_str):0;
- buffer_sprintf(w->response.data, "API command 'data' for chart '%s', dimensions '%s', after '%s', before '%s', points '%s', group '%s', format '%s', options '%s'", chart, dim, after_str, before_str, points_str, group_str, format, options);
+ debug(D_WEB_CLIENT, "%llu: API command 'data' for chart '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%u', format '%u', options '0x%08x'"
+ , w->id
+ , chart
+ , (dimensions)?buffer_tostring(dimensions):""
+ , after
+ , before
+ , points
+ , group
+ , format
+ , options
+ );
+
+ if(outFileName && *outFileName) {
+ buffer_sprintf(w->response.header, "Content-Disposition: attachment; filename=\"%s\"\r\n", outFileName);
+ error("generating outfilename header: '%s'", outFileName);
+ }
+
+ if(format == DATASOURCE_DATATABLE_JSONP) {
+ if(responseHandler == NULL)
+ responseHandler = "google.visualization.Query.setResponse";
+
+ debug(D_WEB_CLIENT_ACCESS, "%llu: GOOGLE JSON/JSONP: version = '%s', reqId = '%s', sig = '%s', out = '%s', responseHandler = '%s', outFileName = '%s'",
+ w->id, google_version, google_reqId, google_sig, google_out, responseHandler, outFileName
+ );
+
+ buffer_sprintf(w->response.data,
+ "%s({version:'%s',reqId:'%s',status:'ok',sig:'%lu',table:",
+ responseHandler, google_version, google_reqId, st->last_updated.tv_sec);
+ }
+ else if(format == DATASOURCE_JSONP) {
+ if(responseHandler == NULL)
+ responseHandler = "callback";
+
+ buffer_strcat(w->response.data, responseHandler);
+ buffer_strcat(w->response.data, "(");
+ }
+
+ ret = rrd2format(st, w->response.data, dimensions, format, points, after, before, group, options, &last_timestamp_in_data);
+
+ if(format == DATASOURCE_DATATABLE_JSONP) {
+ if(google_timestamp < last_timestamp_in_data)
+ buffer_strcat(w->response.data, "});");
+
+ else {
+ // the client already has the latest data
+ buffer_flush(w->response.data);
+ buffer_sprintf(w->response.data,
+ "%s({version:'%s',reqId:'%s',status:'error',errors:[{reason:'not_modified',message:'Data not modified'}]});",
+ responseHandler, google_version, google_reqId);
+ }
+ }
+ else if(format == DATASOURCE_JSONP)
+ buffer_strcat(w->response.data, ");");
cleanup:
if(dimensions) buffer_free(dimensions);
char *google_out = "json";
char *google_responseHandler = "google.visualization.Query.setResponse";
char *google_outFileName = NULL;
- unsigned long last_timestamp_in_data = 0;
- if(datasource_type == DATASOURCE_GOOGLE_JSON || datasource_type == DATASOURCE_GOOGLE_JSONP) {
+ time_t last_timestamp_in_data = 0;
+ if(datasource_type == DATASOURCE_DATATABLE_JSON || datasource_type == DATASOURCE_DATATABLE_JSONP) {
w->response.data->contenttype = CT_APPLICATION_X_JAVASCRIPT;
w->id, google_version, google_reqId, google_sig, google_out, google_responseHandler, google_outFileName
);
- if(datasource_type == DATASOURCE_GOOGLE_JSONP) {
+ if(datasource_type == DATASOURCE_DATATABLE_JSONP) {
last_timestamp_in_data = strtoul(google_sig, NULL, 0);
// check the client wants json
}
}
- if(datasource_type == DATASOURCE_GOOGLE_JSONP) {
+ if(datasource_type == DATASOURCE_DATATABLE_JSONP) {
buffer_sprintf(w->response.data,
"%s({version:'%s',reqId:'%s',status:'ok',sig:'%lu',table:",
google_responseHandler, google_version, google_reqId, st->last_updated.tv_sec);
}
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending RRD data '%s' (id %s, %d lines, %d group, %d group_method, %lu after, %lu before).", w->id, st->name, st->id, lines, group_count, group_method, after, before);
- unsigned long timestamp_in_data = rrd_stats_json(datasource_type, st, w->response.data, lines, group_count, group_method, after, before, nonzero);
+ time_t timestamp_in_data = rrd_stats_json(datasource_type, st, w->response.data, lines, group_count, group_method, after, before, nonzero);
- if(datasource_type == DATASOURCE_GOOGLE_JSONP) {
+ if(datasource_type == DATASOURCE_DATATABLE_JSONP) {
if(timestamp_in_data > last_timestamp_in_data)
buffer_strcat(w->response.data, "});");
else {
// the client already has the latest data
+ buffer_flush(w->response.data);
buffer_sprintf(w->response.data,
"%s({version:'%s',reqId:'%s',status:'error',errors:[{reason:'not_modified',message:'Data not modified'}]});",
google_responseHandler, google_version, google_reqId);
void web_client_process(struct web_client *w) {
int code = 500;
- int bytes;
+ ssize_t bytes;
w->wait_receive = 0;
web_client_enable_deflate(w);
#endif // NETDATA_WITH_ZLIB
- int datasource_type = DATASOURCE_GOOGLE_JSONP;
+ int datasource_type = DATASOURCE_DATATABLE_JSONP;
//if(strstr(w->response.data->buffer, "X-DataSource-Auth"))
// datasource_type = DATASOURCE_GOOGLE_JSON;
- char *buf = w->response.data->buffer;
+ char *buf = (char *)buffer_tostring(w->response.data);
char *tok = strsep(&buf, " \r\n");
char *url = NULL;
char *pointer_to_free = NULL; // keep url_decode() allocated buffer
datasource_type = DATASOURCE_JSON;
code = web_client_api_request(w, url);
}
+#ifdef NETDATA_INTERNAL_CHECKS
+ else if(strcmp(tok, "exit") == 0) {
+ netdata_exit = 1;
+ code = 200;
+ w->response.data->contenttype = CT_TEXT_PLAIN;
+ buffer_flush(w->response.data);
+ buffer_strcat(w->response.data, "will do");
+ }
+#endif
else if(strcmp(tok, WEB_PATH_DATA) == 0) { // "data"
// the client is requesting rrd data
datasource_type = DATASOURCE_JSON;
rrd_stats_graph_json(st, url, w->response.data);
}
}
+#ifdef NETDATA_INTERNAL_CHECKS
else if(strcmp(tok, "debug") == 0) {
buffer_flush(w->response.data);
// just leave the buffer as is
// it will be copied back to the client
}
+#endif
else if(strcmp(tok, "list") == 0) {
code = 200;
// prepare the HTTP response header
debug(D_WEB_CLIENT, "%llu: Generating HTTP header with response %d.", w->id, code);
- char *content_type_string = "";
+ char *content_type_string;
switch(w->response.data->contenttype) {
case CT_TEXT_HTML:
content_type_string = "text/html; charset=utf-8";
content_type_string = "application/font-woff";
break;
+ case CT_APPLICATION_FONT_WOFF2:
+ content_type_string = "application/font-woff2";
+ break;
+
case CT_APPLICATION_VND_MS_FONTOBJ:
content_type_string = "application/vnd.ms-fontobject";
break;
break;
}
- char *code_msg = "";
+ char *code_msg;
switch(code) {
case 200:
code_msg = "OK";
}
char date[100];
- struct tm tm = *gmtime(&w->response.data->date);
- strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %Z", &tm);
+ struct tm tmbuf, *tm = gmtime_r(&w->response.data->date, &tmbuf);
+ strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %Z", tm);
buffer_sprintf(w->response.header_output,
"HTTP/1.1 %d %s\r\n"
"Server: NetData Embedded HTTP Server\r\n"
"Content-Type: %s\r\n"
"Access-Control-Allow-Origin: *\r\n"
+ "Access-Control-Allow-Methods: GET\r\n"
+ "Access-Control-Allow-Headers: x-requested-with\r\n"
"Date: %s\r\n"
, code, code_msg
, w->keepalive?"keep-alive":"close"
buffer_sprintf(w->response.header_output,
"Expires: %s\r\n"
"Cache-Control: no-cache\r\n"
+ "Access-Control-Max-Age: 0\r\n"
, date);
}
- else
+ else {
buffer_strcat(w->response.header_output, "Cache-Control: public\r\n");
+ buffer_strcat(w->response.header_output, "Access-Control-Max-Age: 3600\r\n");
+ }
// if we know the content length, put it
if(!w->response.zoutput && (w->response.data->len || w->response.rlen))
buffer_sprintf(w->response.header_output,
"Content-Length: %ld\r\n"
- , w->response.data->len?w->response.data->len:w->response.rlen
+ , w->response.data->len? w->response.data->len: w->response.rlen
);
else if(!w->response.zoutput)
w->keepalive = 0; // content-length is required for keep-alive
);
bytes = send(w->ofd, buffer_tostring(w->response.header_output), buffer_strlen(w->response.header_output), 0);
- if(bytes != buffer_strlen(w->response.header_output))
+ if(bytes != (ssize_t) buffer_strlen(w->response.header_output))
error("%llu: HTTP Header failed to be sent (I sent %d bytes but the system sent %d bytes)."
, w->id
, buffer_strlen(w->response.header_output)
}
}
-long web_client_send_chunk_header(struct web_client *w, int len)
+long web_client_send_chunk_header(struct web_client *w, long len)
{
debug(D_DEFLATE, "%llu: OPEN CHUNK of %d bytes (hex: %x).", w->id, len, len);
char buf[1024];
- sprintf(buf, "%X\r\n", len);
- int bytes = send(w->ofd, buf, strlen(buf), MSG_DONTWAIT);
+ sprintf(buf, "%lX\r\n", len);
+ ssize_t bytes = send(w->ofd, buf, strlen(buf), MSG_DONTWAIT);
if(bytes > 0) debug(D_DEFLATE, "%llu: Sent chunk header %d bytes.", w->id, bytes);
else if(bytes == 0) debug(D_DEFLATE, "%llu: Did not send chunk header to the client.", w->id);
- else debug(D_DEFLATE, "%llu: Failed to send chunk header to client. Reason: %s", w->id, strerror(errno));
+ else debug(D_DEFLATE, "%llu: Failed to send chunk header to client.", w->id);
return bytes;
}
{
//debug(D_DEFLATE, "%llu: CLOSE CHUNK.", w->id);
- int bytes = send(w->ofd, "\r\n", 2, MSG_DONTWAIT);
+ ssize_t bytes = send(w->ofd, "\r\n", 2, MSG_DONTWAIT);
if(bytes > 0) debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
else if(bytes == 0) debug(D_DEFLATE, "%llu: Did not send chunk suffix to the client.", w->id);
- else debug(D_DEFLATE, "%llu: Failed to send chunk suffix to client. Reason: %s", w->id, strerror(errno));
+ else debug(D_DEFLATE, "%llu: Failed to send chunk suffix to client.", w->id);
return bytes;
}
{
//debug(D_DEFLATE, "%llu: FINALIZE CHUNK.", w->id);
- int bytes = send(w->ofd, "\r\n0\r\n\r\n", 7, MSG_DONTWAIT);
+ ssize_t bytes = send(w->ofd, "\r\n0\r\n\r\n", 7, MSG_DONTWAIT);
if(bytes > 0) debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
else if(bytes == 0) debug(D_DEFLATE, "%llu: Did not send chunk suffix to the client.", w->id);
- else debug(D_DEFLATE, "%llu: Failed to send chunk suffix to client. Reason: %s", w->id, strerror(errno));
+ else debug(D_DEFLATE, "%llu: Failed to send chunk suffix to client.", w->id);
return bytes;
}
// give the compressor all the data not passed through the compressor yet
if(w->response.data->len > w->response.sent) {
w->response.zstream.next_in = (Bytef *)&w->response.data->buffer[w->response.sent];
- w->response.zstream.avail_in = (w->response.data->len - w->response.sent);
+ w->response.zstream.avail_in = (uInt) (w->response.data->len - w->response.sent);
}
// reset the compressor output buffer
t += web_client_send_chunk_header(w, w->response.zhave);
}
- len = send(w->ofd, &w->response.zbuffer[w->response.zsent], w->response.zhave - w->response.zsent, MSG_DONTWAIT);
+ len = send(w->ofd, &w->response.zbuffer[w->response.zsent], (size_t) (w->response.zhave - w->response.zsent), MSG_DONTWAIT);
if(len > 0) {
w->response.zsent += len;
if(t > 0) len += t;
debug(D_WEB_CLIENT, "%llu: Sent %d bytes.", w->id, bytes);
}
else if(likely(bytes == 0)) debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client.", w->id);
- else debug(D_WEB_CLIENT, "%llu: Failed to send data to client. Reason: %s", w->id, strerror(errno));
+ else debug(D_WEB_CLIENT, "%llu: Failed to send data to client.", w->id);
return(bytes);
}
long bytes;
if(unlikely(w->mode == WEB_CLIENT_MODE_FILECOPY))
- bytes = read(w->ifd, &w->response.data->buffer[w->response.data->len], (left-1));
+ bytes = read(w->ifd, &w->response.data->buffer[w->response.data->len], (size_t) (left - 1));
else
- bytes = recv(w->ifd, &w->response.data->buffer[w->response.data->len], left-1, MSG_DONTWAIT);
+ bytes = recv(w->ifd, &w->response.data->buffer[w->response.data->len], (size_t) (left - 1), MSG_DONTWAIT);
if(likely(bytes > 0)) {
- int old = w->response.data->len;
+ size_t old = w->response.data->len;
w->response.data->len += bytes;
w->response.data->buffer[w->response.data->len] = '\0';
}
if(FD_ISSET(w->ifd, &efds)) {
- debug(D_WEB_CLIENT_ACCESS, "%llu: Received error on input socket (%s).", w->id, strerror(errno));
+ debug(D_WEB_CLIENT_ACCESS, "%llu: Received error on input socket.", w->id);
break;
}
if(FD_ISSET(w->ofd, &efds)) {
- debug(D_WEB_CLIENT_ACCESS, "%llu: Received error on output socket (%s).", w->id, strerror(errno));
+ debug(D_WEB_CLIENT_ACCESS, "%llu: Received error on output socket.", w->id);
break;
}
if(w->wait_send && FD_ISSET(w->ofd, &ofds)) {
long bytes;
if((bytes = web_client_send(w)) < 0) {
- debug(D_WEB_CLIENT, "%llu: Cannot send data to client. Closing client (ouput: %s).", w->id, strerror(errno));
+ debug(D_WEB_CLIENT, "%llu: Cannot send data to client. Closing client.", w->id);
errno = 0;
break;
}
if(w->wait_receive && FD_ISSET(w->ifd, &ifds)) {
long bytes;
if((bytes = web_client_receive(w)) < 0) {
- debug(D_WEB_CLIENT, "%llu: Cannot receive data from client. Closing client (input: %s).", w->id, strerror(errno));
+ debug(D_WEB_CLIENT, "%llu: Cannot receive data from client. Closing client.", w->id);
errno = 0;
break;
}