4 #include <sys/socket.h>
5 #include <netinet/in.h>
9 #include "web_buffer.h"
11 #define DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS 60
12 extern int web_client_timeout;
13 extern int web_enable_gzip;
15 #ifndef NETDATA_WEB_CLIENT_H
16 #define NETDATA_WEB_CLIENT_H 1
18 #define WEB_CLIENT_MODE_NORMAL 0
19 #define WEB_CLIENT_MODE_FILECOPY 1
22 #define ZLIB_CHUNK 16384
23 #define MAX_HTTP_HEADER_SIZE 16384
30 struct name_value *next;
39 struct name_value *headers;
40 struct name_value *query_parameters;
41 struct name_value *post_parameters;
46 unsigned long long id;
48 char client_ip[NI_MAXHOST+1];
49 char client_port[NI_MAXSERV+1];
51 char last_url[URL_MAX+1];
53 struct web_request *request;
55 struct timeval tv_in, tv_ready;
60 struct sockaddr_storage clientaddr;
62 pthread_t thread; // the thread servicing this client
63 int obsolete; // if set to 1, the listener will remove this client
68 struct web_buffer *data;
70 int zoutput; // if set to 1, web_client_send() will send compressed data
71 z_stream zstream; // zlib stream for sending compressed output to client
72 Bytef zbuffer[ZLIB_CHUNK]; // temporary buffer for storing compressed output
73 long zsent; // the compressed bytes we have sent to the client
74 long zhave; // the compressed bytes that we have to send
80 char response_header[MAX_HTTP_HEADER_SIZE+1];
82 struct web_client *prev;
83 struct web_client *next;
86 extern struct web_client *web_clients;
88 extern struct web_client *web_client_create(int listener);
89 extern struct web_client *web_client_free(struct web_client *w);
91 extern void *web_client_main(void *ptr);